Skip to content

Commit 2eae37d

Browse files
committed
Update ref docs on ResponseEntity and reactive types
Issue: SPR-17400
1 parent 42b7c5a commit 2eae37d

File tree

2 files changed

+25
-16
lines changed

2 files changed

+25
-16
lines changed

src/docs/asciidoc/web/webflux.adoc

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2414,22 +2414,26 @@ configure or customize message writing.
24142414
==== `ResponseEntity`
24152415
[.small]#<<web.adoc#mvc-ann-responseentity,Same as in Spring MVC>>#
24162416

2417-
Using `ResponseEntity` is more or less identical to using <<webflux-ann-responsebody>> but is based
2418-
on a container object that specifies request headers and body. The following example uses `ResponseEntity`:
2417+
`ResponseEntity` is like <<webflux-ann-responsebody>> but with status and headers. For example:
24192418

24202419
====
24212420
[source,java,indent=0]
24222421
[subs="verbatim,quotes"]
24232422
----
2424-
@PostMapping("/something")
2423+
@GetMapping("/something")
24252424
public ResponseEntity<String> handle() {
2426-
// ...
2427-
URI location = ...
2428-
return new ResponseEntity.created(location).build();
2425+
String body = ... ;
2426+
String etag = ... ;
2427+
return ResponseEntity.ok().eTag(etag).build(body);
24292428
}
24302429
----
24312430
====
24322431

2432+
WebFlux supports using a single value <<webflux-reactive-libraries,reactive type>> to
2433+
produce the `ResponseEntity` asynchronously, and/or single and multi-value reactive types
2434+
for the body.
2435+
2436+
24332437

24342438

24352439
[[webflux-ann-jackson]]

src/docs/asciidoc/web/webmvc.adoc

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2789,22 +2789,26 @@ See <<mvc-ann-jackson>> for details.
27892789
==== ResponseEntity
27902790
[.small]#<<web-reactive.adoc#webflux-ann-responseentity,Same as in Spring WebFlux>>#
27912791

2792-
`ResponseEntity` is more or less identical to using <<mvc-ann-responsebody>> but is based
2793-
on a container object that specifies request headers and body. The following listing shows an example:
2792+
`ResponseEntity` is like <<mvc-ann-responsebody>> but with status and headers. For example:
27942793

27952794
====
27962795
[source,java,indent=0]
27972796
[subs="verbatim,quotes"]
27982797
----
2799-
@PostMapping("/something")
2798+
@GetMapping("/something")
28002799
public ResponseEntity<String> handle() {
2801-
// ...
2802-
URI location = ... ;
2803-
return ResponseEntity.created(location).build();
2800+
String body = ... ;
2801+
String etag = ... ;
2802+
return ResponseEntity.ok().eTag(etag).build(body);
28042803
}
28052804
----
28062805
====
28072806

2807+
Spring MVC supports using a single value <<mvc-ann-async-reactive-types,reactive type>>
2808+
to produce the `ResponseEntity` asynchronously, and/or single and multi-value reactive
2809+
types for the body.
2810+
2811+
28082812

28092813

28102814
[[mvc-ann-jackson]]
@@ -3854,10 +3858,11 @@ customize the status and headers of the response.
38543858
=== Reactive Types
38553859
[.small]#<<web-reactive.adoc#webflux-codecs-streaming,Same as in Spring WebFlux>>#
38563860

3857-
Spring MVC supports use of reactive client libraries in a controller. This includes the
3858-
`WebClient` from `spring-webflux` and others, such as Spring Data reactive data
3859-
repositories. In such scenarios, it is convenient to be able to return reactive types
3860-
from the controller method .
3861+
Spring MVC supports use of reactive client libraries in a controller (also read
3862+
<<web-reactive.adoc#webflux-reactive-libraries,Reactive Libraries>> in the WebFlux section).
3863+
This includes the `WebClient` from `spring-webflux` and others, such as Spring Data
3864+
reactive data repositories. In such scenarios, it is convenient to be able to return
3865+
reactive types from the controller method.
38613866

38623867
Reactive return values are handled as follows:
38633868

0 commit comments

Comments
 (0)