We are implementing a REST API with Spring (4.1.1.). For certain HTTP requests, we would like to return a head with no body as a response. However, using ResponseEntit
According Spring 4 MVC ResponseEntity.BodyBuilder and ResponseEntity Enhancements Example it could be written as:
....
return ResponseEntity.ok().build();
....
return ResponseEntity.noContent().build();
UPDATE:
If returned value is Optional
there are convinient method, returned ok()
or notFound()
:
return ResponseEntity.of(optional)