Spring WebClient retrieve() vs exchange()

This commit is contained in:
michaelin007 2024-04-25 04:18:21 +00:00
parent c8ef6f2fd3
commit 2f1cd9a53c
1 changed files with 1 additions and 5 deletions

View File

@ -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()) {