Skip to content

Instantly share code, notes, and snippets.

@codingtim
Created November 18, 2018 14:25
Show Gist options
  • Select an option

  • Save codingtim/c5b07a679d146db47aa825f184945c8e to your computer and use it in GitHub Desktop.

Select an option

Save codingtim/c5b07a679d146db47aa825f184945c8e to your computer and use it in GitHub Desktop.

Revisions

  1. codingtim created this gist Nov 18, 2018.
    18 changes: 18 additions & 0 deletions ApiCaller.java
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    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);
    }
    }