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}")
|
||||
Mono<User> retrieveOneUserAndHandleErrorBaseOnStatus(@PathVariable int id) {
|
||||
Mono<User> retrieveOneUserAndHandleErrorBasedOnStatus(@PathVariable int id) {
|
||||
return client.get()
|
||||
.uri("/{id}", id)
|
||||
.retrieve()
|
||||
|
@ -76,10 +76,6 @@ public class RetrieveAndExchangeController {
|
|||
.exchangeToMono(res -> {
|
||||
if (res.statusCode()
|
||||
.is2xxSuccessful()) {
|
||||
logger.info("Status code: " + res.headers()
|
||||
.asHttpHeaders());
|
||||
logger.info("Content-type" + res.headers()
|
||||
.contentType());
|
||||
return res.bodyToMono(User.class);
|
||||
} else if (res.statusCode()
|
||||
.is4xxClientError()) {
|
||||
|
|
Loading…
Reference in New Issue