Document choices for async ResponseEntity return values

Closes gh-22614
This commit is contained in:
Rossen Stoyanchev
2021-01-12 14:36:10 +00:00
parent ea4fe7eaf7
commit c3c36ab498
2 changed files with 19 additions and 2 deletions

View File

@@ -2993,7 +2993,17 @@ configure or customize message writing.
WebFlux supports using a single value <<webflux-reactive-libraries, reactive type>> to
produce the `ResponseEntity` asynchronously, and/or single and multi-value reactive types
for the body.
for the body. This allows a variety of async responses with `ResponseEntity` as follows:
* `ResponseEntity<Mono<T>>` or `ResponseEntity<Flux<T>>` make the response status and
headers known immediately while the body is provided asynchronously at a later point.
Use `Mono` if the body consists of 0..1 values or `Flux` if it can produce multiple values.
* `Mono<ResponseEntity<T>>` provides all three -- response status, headers, and body,
asynchronously at a later point. This allows the response status and headers to vary
depending on the outcome of asynchronous request handling.
* `Mono<ResponseEntity<Mono<T>>>` or `Mono<ResponseEntity<Flux<T>>>` are yet another
possible, albeit less common alternative. They provides the response status and headers
asynchronously first and then the response body, also asynchronously at a second point later.
[[webflux-ann-jackson]]

View File

@@ -3316,7 +3316,14 @@ See <<mvc-ann-jackson>> for details.
Spring MVC supports using a single value <<mvc-ann-async-reactive-types, reactive type>>
to produce the `ResponseEntity` asynchronously, and/or single and multi-value reactive
types for the body.
types for the body. This allows the following types of async responses:
* `ResponseEntity<Mono<T>>` or `ResponseEntity<Flux<T>>` make the response status and
headers known immediately while the body is provided asynchronously at a later point.
Use `Mono` if the body consists of 0..1 values or `Flux` if it can produce multiple values.
* `Mono<ResponseEntity<T>>` provides all three -- response status, headers, and body,
asynchronously at a later point. This allows the response status and headers to vary
depending on the outcome of asynchronous request handling.
[[mvc-ann-jackson]]