Skip to content

Commit

Permalink
Merge branch '5.3.x' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
rstoyanchev committed Dec 3, 2021
2 parents ba568ff + 5649a6f commit a9d2016
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 17 deletions.
Expand Up @@ -519,16 +519,13 @@ interface RequestHeadersSpec<S extends RequestHeadersSpec<S>> {
* 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.createError();
* }
Expand All @@ -551,18 +548,15 @@ interface RequestHeadersSpec<S extends RequestHeadersSpec<S>> {
* 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.createError().flux();
* }
* });
* </pre>
Expand Down
9 changes: 1 addition & 8 deletions src/docs/asciidoc/web/webflux-webclient.adoc
Expand Up @@ -582,17 +582,13 @@ depending on the response status:
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
.Java
----
Mono<Object> entityMono = client.get()
Mono<Person> entityMono = client.get()
.uri("/persons/1")
.accept(MediaType.APPLICATION_JSON)
.exchangeToMono(response -> {
if (response.statusCode().equals(HttpStatus.OK)) {
return response.bodyToMono(Person.class);
}
else if (response.statusCode().is4xxClientError()) {
// Suppress error status code
return response.bodyToMono(ErrorContainer.class);
}
else {
// Turn to error
return response.createError();
Expand All @@ -609,9 +605,6 @@ val entity = client.get()
if (response.statusCode() == HttpStatus.OK) {
return response.awaitBody<Person>()
}
else if (response.statusCode().is4xxClientError) {
return response.awaitBody<ErrorContainer>()
}
else {
throw response.createExceptionAndAwait()
}
Expand Down

0 comments on commit a9d2016

Please sign in to comment.