Update exchangeToMono Javadoc

This time showing a more representative example.

See gh-27645
This commit is contained in:
Rossen Stoyanchev
2021-12-03 09:21:21 +00:00
parent be6eeafe78
commit 5649a6f8ef
2 changed files with 6 additions and 19 deletions

View File

@@ -519,18 +519,15 @@ public interface WebClient {
* scenarios, for example to decode the response differently depending
* on the response status:
* <p><pre>
* Mono&lt;Object&gt; entityMono = client.get()
* Mono&lt;Person&gt; entityMono = client.get()
* .uri("/persons/1")
* .accept(MediaType.APPLICATION_JSON)
* .exchangeToMono(response -&gt; {
* if (response.statusCode().equals(HttpStatus.OK)) {
* return response.bodyToMono(Person.class);
* }
* else if (response.statusCode().is4xxClientError()) {
* return response.bodyToMono(ErrorContainer.class);
* }
* else {
* return response.createException();
* return response.createException().flatMap(Mono::error);
* }
* });
* </pre>
@@ -551,18 +548,15 @@ public interface WebClient {
* scenarios, for example to decode the response differently depending
* on the response status:
* <p><pre>
* Mono&lt;Object&gt; entityMono = client.get()
* Flux&lt;Person&gt; entityMono = client.get()
* .uri("/persons")
* .accept(MediaType.APPLICATION_JSON)
* .exchangeToFlux(response -&gt; {
* if (response.statusCode().equals(HttpStatus.OK)) {
* return response.bodyToFlux(Person.class);
* }
* else if (response.statusCode().is4xxClientError()) {
* return response.bodyToMono(ErrorContainer.class).flux();
* }
* else {
* return response.createException().flux();
* return response.createException().flatMapMany(Mono::error);
* }
* });
* </pre>