ResponseEntity<Single<>> instead of Single<ResponseEntity<>>
See original GitHub issueThe new code introduced here allows the controller to return Single
or Observable
.
Although it has some flaws handling the http status code.
- It does not honor
@ResponseStatus
annotations on the controller itself. - It does support
ResponseEntity<Single<>>
which is useless in any case where the status code depends on the reactive code, for instance: it is impossible to write a properResponseEntity<Single<User>> findUser()
method as it will necessarily subscribe and consume the Single at the controller instead of at the response handler. - It doesn’t implement support for Completable.
Issue Analytics
- State:
- Created 7 years ago
- Comments:10 (4 by maintainers)
Top Results From Across the Web
java - What is the best way to return different types of ...
One solution is to use ResponseEntity<Object> . An other is to use the a BaseClass or Interface for types Success and Error. –...
Read more >Using Spring ResponseEntity to Manipulate the HTTP Response
In this short tutorial, we'll see how to set the body, status, and headers of an HTTP response using ResponseEntity.
Read more >ResponseEntity (Spring Framework 6.0.2 API)
Extension of HttpEntity that adds an HttpStatusCode status code. Used in RestTemplate as well as in @Controller methods. In RestTemplate , this class...
Read more >Using ResponseEntity in Spring Application - Java Guides
ResponseEntity represents an HTTP response, including headers, body, and status. While @ResponseBody puts the return value into the body of the response, ...
Read more >Using ResponseEntity in Spring - Technicalsand
ResponseEntity and RequestEntity both are the extensions of HttpEntity. ResponseEntity represents an HTTP response including status, headers and ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Indeed it looks like there is no way to vary the status based on the outcome. In other words it should deal with
Single<ResponseEntity<>>
.Not sure what’s the issue with
@ResponseStatus
. That should be set regardless of the return value handler used. Perhaps it’s getting overridden later when the Single completes?now 1.2.0.RELEASE