Skip to content

Instantly share code, notes, and snippets.

@codingtim
Created November 18, 2018 14:25
Show Gist options
  • Save codingtim/c5b07a679d146db47aa825f184945c8e to your computer and use it in GitHub Desktop.
Save codingtim/c5b07a679d146db47aa825f184945c8e to your computer and use it in GitHub Desktop.
WebClient calling an imaginary web api
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