Created
November 18, 2018 14:25
-
-
Save codingtim/c5b07a679d146db47aa825f184945c8e to your computer and use it in GitHub Desktop.
WebClient calling an imaginary web api
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApiCaller { | |
private WebClient webClient; | |
ApiCaller(WebClient webClient) { | |
this.webClient = webClient; | |
} | |
Mono<SimpleResponseDto> callApi() { | |
return webClient.put() | |
.uri("/api/resource") | |
.contentType(MediaType.APPLICATION_JSON) | |
.header("Authorization", "customAuth") | |
.syncBody(new SimpleRequestDto()) | |
.retrieve() | |
.bodyToMono(SimpleResponseDto.class); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment