Example usage for org.springframework.web.reactive.function.client WebClient builder

List of usage examples for org.springframework.web.reactive.function.client WebClient builder

Introduction

In this page you can find the example usage for org.springframework.web.reactive.function.client WebClient builder.

Prototype

static WebClient.Builder builder() 

Source Link

Document

Obtain a WebClient builder.

Usage

From source file:org.springframework.cloud.gateway.filter.headers.NonStandardHeadersInResponseTests.java

@Test
public void nonStandardHeadersInResponse() {
    URI uri = UriComponentsBuilder.fromUriString(this.baseUri + "/get-image").build(true).toUri();

    String contentType = WebClient.builder().baseUrl(baseUri).build().get().uri(uri).exchange()
            .map(clientResponse -> clientResponse.headers().asHttpHeaders().getFirst(HttpHeaders.CONTENT_TYPE))
            .block();/* www. j a  v a 2 s  .  com*/

    assertThat(contentType).isEqualTo(CONTENT_TYPE_IMAGE);
}

From source file:org.springframework.cloud.sleuth.instrument.web.client.TraceWebClientBeanPostProcessor.java

@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
    if (bean instanceof WebClient) {
        WebClient webClient = (WebClient) bean;
        return webClient.mutate().filters(addTraceExchangeFilterFunctionIfNotPresent()).build();
    } else if (bean instanceof WebClient.Builder) {
        WebClient.Builder webClientBuilder = (WebClient.Builder) bean;
        return webClientBuilder.filters(addTraceExchangeFilterFunctionIfNotPresent());
    }//www.j a  va2s .c o  m
    return bean;
}