Interface WebClient.Builder
- Enclosing interface:
- WebClient
WebClient.- 
Method SummaryModifier and TypeMethodDescriptionapply(Consumer<WebClient.Builder> builderConsumer) Apply the givenConsumerto this builder instance.Configure a base URL for requests.build()Builder theWebClientinstance.clientConnector(ClientHttpConnector connector) Configure theClientHttpConnectorto use.clone()Clone thisWebClient.Builder.codecs(Consumer<ClientCodecConfigurer> configurer) defaultCookie(String cookie, String... values) Global option to specify a cookie to be added to every request, if the request does not already contain such a cookie.defaultCookies(Consumer<MultiValueMap<String, String>> cookiesConsumer) Provides access to everydefaultCookie(String, String...)declared so far with the possibility to add, replace, or remove.defaultHeader(String header, String... values) Global option to specify a header to be added to every request, if the request does not already contain such a header.defaultHeaders(Consumer<HttpHeaders> headersConsumer) Provides access to everydefaultHeader(String, String...)declared so far with the possibility to add, replace, or remove.defaultRequest(Consumer<WebClient.RequestHeadersSpec<?>> defaultRequest) Provide a consumer to customize every request being built.defaultUriVariables(Map<String, ?> defaultUriVariables) Configure default URL variable values to use when expanding URI templates with aMap.exchangeFunction(ExchangeFunction exchangeFunction) exchangeStrategies(Consumer<ExchangeStrategies.Builder> configurer) Deprecated.exchangeStrategies(ExchangeStrategies strategies) Configure theExchangeStrategiesto use.filter(ExchangeFilterFunction filter) Add the given filter to the end of the filter chain.filters(Consumer<List<ExchangeFilterFunction>> filtersConsumer) Manipulate the filters with the given consumer.uriBuilderFactory(UriBuilderFactory uriBuilderFactory) Provide a pre-configuredUriBuilderFactoryinstance.
- 
Method Details- 
baseUrlConfigure a base URL for requests. Effectively a shortcut for:String baseUrl = "https://abc.go.com/v1"; DefaultUriBuilderFactory factory = new DefaultUriBuilderFactory(baseUrl); WebClient client = WebClient.builder().uriBuilderFactory(factory).build(); The DefaultUriBuilderFactoryis used to prepare the URL for every request with the given base URL, unless the URL request for a given URL is absolute in which case the base URL is ignored.Note: this method is mutually exclusive with uriBuilderFactory(UriBuilderFactory). If both are used, the baseUrl value provided here will be ignored.
- 
defaultUriVariablesConfigure default URL variable values to use when expanding URI templates with aMap. Effectively a shortcut for:Map<String, ?> defaultVars = ...; DefaultUriBuilderFactory factory = new DefaultUriBuilderFactory(); factory.setDefaultVariables(defaultVars); WebClient client = WebClient.builder().uriBuilderFactory(factory).build(); Note: this method is mutually exclusive with uriBuilderFactory(UriBuilderFactory). If both are used, the defaultUriVariables value provided here will be ignored.
- 
uriBuilderFactoryProvide a pre-configuredUriBuilderFactoryinstance. This is an alternative to, and effectively overrides the following shortcut properties:- Parameters:
- uriBuilderFactory- the URI builder factory to use
- See Also:
 
- 
defaultHeaderGlobal option to specify a header to be added to every request, if the request does not already contain such a header.- Parameters:
- header- the header name
- values- the header values
 
- 
defaultHeadersProvides access to everydefaultHeader(String, String...)declared so far with the possibility to add, replace, or remove.- Parameters:
- headersConsumer- the consumer
 
- 
defaultCookieGlobal option to specify a cookie to be added to every request, if the request does not already contain such a cookie.- Parameters:
- cookie- the cookie name
- values- the cookie values
 
- 
defaultCookiesProvides access to everydefaultCookie(String, String...)declared so far with the possibility to add, replace, or remove.- Parameters:
- cookiesConsumer- a function that consumes the cookies map
 
- 
defaultRequestProvide a consumer to customize every request being built.- Parameters:
- defaultRequest- the consumer to use for modifying requests
- Since:
- 5.1
 
- 
filterAdd the given filter to the end of the filter chain.- Parameters:
- filter- the filter to be added to the chain
 
- 
filtersManipulate the filters with the given consumer. The list provided to the consumer is "live", so that the consumer can be used to remove filters, change ordering, etc.- Parameters:
- filtersConsumer- a function that consumes the filter list
- Returns:
- this builder
 
- 
clientConnectorConfigure theClientHttpConnectorto use. This is useful for plugging in and/or customizing options of the underlying HTTP client library (e.g. SSL).By default this is set to ReactorClientHttpConnector.- Parameters:
- connector- the connector to use
 
- 
codecs- Parameters:
- configurer- the configurer to apply
- Since:
- 5.1.13
 
- 
exchangeStrategiesConfigure theExchangeStrategiesto use.For most cases, prefer using codecs(Consumer)which allows customizing the codecs in theExchangeStrategiesrather than replace them. That ensures multiple parties can contribute to codecs configuration.By default this is set to ExchangeStrategies.withDefaults().- Parameters:
- strategies- the strategies to use
 
- 
exchangeStrategiesDeprecated.as of 5.1.13 in favor ofcodecs(Consumer)Customize the strategies configured viaexchangeStrategies(ExchangeStrategies). This method is designed for use in scenarios where multiple parties wish to update theExchangeStrategies.
- 
exchangeFunctionProvide anExchangeFunctionpre-configured withClientHttpConnectorandExchangeStrategies.This is an alternative to, and effectively overrides clientConnector(org.springframework.http.client.reactive.ClientHttpConnector), andexchangeStrategies(ExchangeStrategies).- Parameters:
- exchangeFunction- the exchange function to use
 
- 
applyApply the givenConsumerto this builder instance.This can be useful for applying pre-packaged customizations. - Parameters:
- builderConsumer- the consumer to apply
 
- 
cloneWebClient.Builder clone()Clone thisWebClient.Builder.
- 
buildWebClient build()Builder theWebClientinstance.
 
- 
codecs(Consumer)