Skip to content

Commit d492d7b

Browse files
committed
Update ref docs on ResponseEntity and reactive types
Issue: SPR-17400
1 parent bf4d00c commit d492d7b

File tree

2 files changed

+22
-16
lines changed

2 files changed

+22
-16
lines changed

src/docs/asciidoc/web/webflux.adoc

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2147,19 +2147,21 @@ configure or customize message writing.
21472147
==== ResponseEntity
21482148
[.small]#<<web.adoc#mvc-ann-responseentity,Same in Spring MVC>>#
21492149

2150-
`ResponseEntity` is more or less identical to using <<webflux-ann-responsebody>> but based
2151-
on a container object that specifies request headers and body. Below is an example:
2150+
`ResponseEntity` is like <<webflux-ann-responsebody>> but with status and headers. For example:
21522151

21532152
[source,java,indent=0]
21542153
[subs="verbatim,quotes"]
21552154
----
2156-
@PostMapping("/something")
2155+
@GetMapping("/something")
21572156
public ResponseEntity<String> handle() {
2158-
// ...
2159-
URI location = ...
2160-
return new ResponseEntity.created(location).build();
2157+
String body = ... ;
2158+
String etag = ... ;
2159+
return ResponseEntity.ok().eTag(etag).build(body);
21612160
}
21622161
----
2162+
WebFlux supports using a single value <<webflux-reactive-libraries,reactive type>> to
2163+
produce the `ResponseEntity` asynchronously, and/or single and multi-value reactive types
2164+
for the body.
21632165

21642166

21652167
[[webflux-ann-jackson]]

src/docs/asciidoc/web/webmvc.adoc

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2560,20 +2560,23 @@ See <<mvc-ann-jackson>> for details.
25602560
==== ResponseEntity
25612561
[.small]#<<web-reactive.adoc#webflux-ann-responseentity,Same in Spring WebFlux>>#
25622562

2563-
`ResponseEntity` is more or less identical to using <<mvc-ann-responsebody>> but based
2564-
on a container object that specifies request headers and body. Below is an example:
2563+
`ResponseEntity` is like <<mvc-ann-responsebody>> but with status and headers. For example:
25652564

25662565
[source,java,indent=0]
25672566
[subs="verbatim,quotes"]
25682567
----
2569-
@PostMapping("/something")
2568+
@GetMapping("/something")
25702569
public ResponseEntity<String> handle() {
2571-
// ...
2572-
URI location = ... ;
2573-
return ResponseEntity.created(location).build();
2570+
String body = ... ;
2571+
String etag = ... ;
2572+
return ResponseEntity.ok().eTag(etag).build(body);
25742573
}
25752574
----
25762575

2576+
Spring MVC supports using a single value <<mvc-ann-async-reactive-types,reactive type>>
2577+
to produce the `ResponseEntity` asynchronously, and/or single and multi-value reactive
2578+
types for the body.
2579+
25772580

25782581
[[mvc-ann-jackson]]
25792582
==== Jackson JSON
@@ -3617,10 +3620,11 @@ customize the status and headers of the response.
36173620
=== Reactive types
36183621
[.small]#<<web-reactive.adoc#webflux-codecs-streaming,Same in Spring WebFlux>>#
36193622

3620-
Spring MVC supports use of reactive client libraries in a controller. This includes the
3621-
`WebClient` from `spring-webflux` and others such as Spring Data reactive data
3622-
repositories. In such scenarios it is convenient to be able to return reactive types
3623-
from the controller method .
3623+
Spring MVC supports use of reactive client libraries in a controller (also read
3624+
<<web-reactive.adoc#webflux-reactive-libraries,Reactive Libraries>> in the WebFlux section).
3625+
This includes the `WebClient` from `spring-webflux` and others, such as Spring Data
3626+
reactive data repositories. In such scenarios, it is convenient to be able to return
3627+
reactive types from the controller method.
36243628

36253629
Reactive return values are handled as follows:
36263630

0 commit comments

Comments
 (0)