...
WebClientBuilder
används för att skapa upp en REST-klient (WebClient
):
Code Block | ||
---|---|---|
| ||
WebClient webClient = new WebClientBuilder() .withBaseUrl("https://api.github.com/") [1] .withLogbook(...) [2] .withOAuth2Client(...) [3] .withBasicAuthentication(...) [4] .withConnectTimeout(...) [5] .withReadTimeout(...) [6] .build(); [7] ... String user = "Sundsvallskommun"; Mono<List<Repo>> repos = webClient.get() .uri("/users/{user}/repos", user) .retrieve() .onStatus(HttpStatus::is4xxClientError, response -> ...) .onStatus(HttpStatus::is5xxServerError, response -> ...) .bodyToMono(new ParameterizedTypeReference<List<Repo>>() {}); ... |
...