Spring WebClient retrieve() vs exchange()
This commit is contained in:
parent
c8ef6f2fd3
commit
2f1cd9a53c
|
@ -29,7 +29,7 @@ public class RetrieveAndExchangeController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/user-status/{id}")
|
@GetMapping("/user-status/{id}")
|
||||||
Mono<User> retrieveOneUserAndHandleErrorBaseOnStatus(@PathVariable int id) {
|
Mono<User> retrieveOneUserAndHandleErrorBasedOnStatus(@PathVariable int id) {
|
||||||
return client.get()
|
return client.get()
|
||||||
.uri("/{id}", id)
|
.uri("/{id}", id)
|
||||||
.retrieve()
|
.retrieve()
|
||||||
|
@ -76,10 +76,6 @@ public class RetrieveAndExchangeController {
|
||||||
.exchangeToMono(res -> {
|
.exchangeToMono(res -> {
|
||||||
if (res.statusCode()
|
if (res.statusCode()
|
||||||
.is2xxSuccessful()) {
|
.is2xxSuccessful()) {
|
||||||
logger.info("Status code: " + res.headers()
|
|
||||||
.asHttpHeaders());
|
|
||||||
logger.info("Content-type" + res.headers()
|
|
||||||
.contentType());
|
|
||||||
return res.bodyToMono(User.class);
|
return res.bodyToMono(User.class);
|
||||||
} else if (res.statusCode()
|
} else if (res.statusCode()
|
||||||
.is4xxClientError()) {
|
.is4xxClientError()) {
|
||||||
|
|
Loading…
Reference in New Issue