From d492d7b6a44f779f296ab6fbf236a51aa30d1805 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Tue, 23 Oct 2018 16:42:31 -0400 Subject: [PATCH] Update ref docs on ResponseEntity and reactive types Issue: SPR-17400 --- src/docs/asciidoc/web/webflux.adoc | 14 ++++++++------ src/docs/asciidoc/web/webmvc.adoc | 24 ++++++++++++++---------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/src/docs/asciidoc/web/webflux.adoc b/src/docs/asciidoc/web/webflux.adoc index c683d75dab8..c4527e8f919 100644 --- a/src/docs/asciidoc/web/webflux.adoc +++ b/src/docs/asciidoc/web/webflux.adoc @@ -2147,19 +2147,21 @@ configure or customize message writing. ==== ResponseEntity [.small]#<># -`ResponseEntity` is more or less identical to using <> but based -on a container object that specifies request headers and body. Below is an example: +`ResponseEntity` is like <> but with status and headers. For example: [source,java,indent=0] [subs="verbatim,quotes"] ---- - @PostMapping("/something") + @GetMapping("/something") public ResponseEntity handle() { - // ... - URI location = ... - return new ResponseEntity.created(location).build(); + String body = ... ; + String etag = ... ; + return ResponseEntity.ok().eTag(etag).build(body); } ---- +WebFlux supports using a single value <> to +produce the `ResponseEntity` asynchronously, and/or single and multi-value reactive types +for the body. [[webflux-ann-jackson]] diff --git a/src/docs/asciidoc/web/webmvc.adoc b/src/docs/asciidoc/web/webmvc.adoc index ae553efb36a..e33ba4e9d6d 100644 --- a/src/docs/asciidoc/web/webmvc.adoc +++ b/src/docs/asciidoc/web/webmvc.adoc @@ -2560,20 +2560,23 @@ See <> for details. ==== ResponseEntity [.small]#<># -`ResponseEntity` is more or less identical to using <> but based -on a container object that specifies request headers and body. Below is an example: +`ResponseEntity` is like <> but with status and headers. For example: [source,java,indent=0] [subs="verbatim,quotes"] ---- - @PostMapping("/something") + @GetMapping("/something") public ResponseEntity handle() { - // ... - URI location = ... ; - return ResponseEntity.created(location).build(); + String body = ... ; + String etag = ... ; + return ResponseEntity.ok().eTag(etag).build(body); } ---- +Spring MVC supports using a single value <> +to produce the `ResponseEntity` asynchronously, and/or single and multi-value reactive +types for the body. + [[mvc-ann-jackson]] ==== Jackson JSON @@ -3617,10 +3620,11 @@ customize the status and headers of the response. === Reactive types [.small]#<># -Spring MVC supports use of reactive client libraries in a controller. This includes the -`WebClient` from `spring-webflux` and others such as Spring Data reactive data -repositories. In such scenarios it is convenient to be able to return reactive types -from the controller method . +Spring MVC supports use of reactive client libraries in a controller (also read +<> in the WebFlux section). +This includes the `WebClient` from `spring-webflux` and others, such as Spring Data +reactive data repositories. In such scenarios, it is convenient to be able to return +reactive types from the controller method. Reactive return values are handled as follows: