Modifier and Type | Method and Description |
---|---|
WebClient.Builder |
apply(Consumer<WebClient.Builder> builderConsumer)
Apply the given
Consumer to this builder instance. |
WebClient.Builder |
baseUrl(String baseUrl)
Configure a base URL for requests.
|
WebClient |
build()
Builder the
WebClient instance. |
WebClient.Builder |
clientConnector(ClientHttpConnector connector)
Configure the
ClientHttpConnector to use. |
WebClient.Builder |
clone()
Clone this
WebClient.Builder . |
WebClient.Builder |
codecs(Consumer<ClientCodecConfigurer> configurer)
|
WebClient.Builder |
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.
|
WebClient.Builder |
defaultCookies(Consumer<MultiValueMap<String,String>> cookiesConsumer)
Provides access to every
defaultCookie(String, String...)
declared so far with the possibility to add, replace, or remove. |
WebClient.Builder |
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.
|
WebClient.Builder |
defaultHeaders(Consumer<HttpHeaders> headersConsumer)
Provides access to every
defaultHeader(String, String...)
declared so far with the possibility to add, replace, or remove. |
WebClient.Builder |
defaultRequest(Consumer<WebClient.RequestHeadersSpec<?>> defaultRequest)
Provide a consumer to customize every request being built.
|
WebClient.Builder |
defaultUriVariables(Map<String,?> defaultUriVariables)
Configure default URL variable values to use when expanding URI
templates with a
Map . |
WebClient.Builder |
exchangeFunction(ExchangeFunction exchangeFunction)
|
WebClient.Builder |
exchangeStrategies(Consumer<ExchangeStrategies.Builder> configurer)
Deprecated.
as of 5.1.13 in favor of
codecs(Consumer) |
WebClient.Builder |
exchangeStrategies(ExchangeStrategies strategies)
Configure the
ExchangeStrategies to use. |
WebClient.Builder |
filter(ExchangeFilterFunction filter)
Add the given filter to the end of the filter chain.
|
WebClient.Builder |
filters(Consumer<List<ExchangeFilterFunction>> filtersConsumer)
Manipulate the filters with the given consumer.
|
WebClient.Builder |
uriBuilderFactory(UriBuilderFactory uriBuilderFactory)
Provide a pre-configured
UriBuilderFactory instance. |
WebClient.Builder baseUrl(String baseUrl)
String baseUrl = "https://abc.go.com/v1"; DefaultUriBuilderFactory factory = new DefaultUriBuilderFactory(baseUrl); WebClient client = WebClient.builder().uriBuilderFactory(factory).build();
The DefaultUriBuilderFactory
is 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.
WebClient.Builder defaultUriVariables(Map<String,?> defaultUriVariables)
Map
. 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.
WebClient.Builder uriBuilderFactory(UriBuilderFactory uriBuilderFactory)
UriBuilderFactory
instance. This is
an alternative to, and effectively overrides the following shortcut
properties:
uriBuilderFactory
- the URI builder factory to usebaseUrl(String)
,
defaultUriVariables(Map)
WebClient.Builder defaultHeader(String header, String... values)
header
- the header namevalues
- the header valuesWebClient.Builder defaultHeaders(Consumer<HttpHeaders> headersConsumer)
defaultHeader(String, String...)
declared so far with the possibility to add, replace, or remove.headersConsumer
- the consumerWebClient.Builder defaultCookie(String cookie, String... values)
cookie
- the cookie namevalues
- the cookie valuesWebClient.Builder defaultCookies(Consumer<MultiValueMap<String,String>> cookiesConsumer)
defaultCookie(String, String...)
declared so far with the possibility to add, replace, or remove.cookiesConsumer
- a function that consumes the cookies mapWebClient.Builder defaultRequest(Consumer<WebClient.RequestHeadersSpec<?>> defaultRequest)
defaultRequest
- the consumer to use for modifying requestsWebClient.Builder filter(ExchangeFilterFunction filter)
filter
- the filter to be added to the chainWebClient.Builder filters(Consumer<List<ExchangeFilterFunction>> filtersConsumer)
filtersConsumer
- a function that consumes the filter listWebClient.Builder clientConnector(ClientHttpConnector connector)
ClientHttpConnector
to 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
.
connector
- the connector to useWebClient.Builder codecs(Consumer<ClientCodecConfigurer> configurer)
configurer
- the configurer to applyWebClient.Builder exchangeStrategies(ExchangeStrategies strategies)
ExchangeStrategies
to use.
For most cases, prefer using codecs(Consumer)
which allows
customizing the codecs in the ExchangeStrategies
rather than
replace them. That ensures multiple parties can contribute to codecs
configuration.
By default this is set to ExchangeStrategies.withDefaults()
.
strategies
- the strategies to use@Deprecated WebClient.Builder exchangeStrategies(Consumer<ExchangeStrategies.Builder> configurer)
codecs(Consumer)
exchangeStrategies(ExchangeStrategies)
. This method is
designed for use in scenarios where multiple parties wish to update
the ExchangeStrategies
.WebClient.Builder exchangeFunction(ExchangeFunction exchangeFunction)
ExchangeFunction
pre-configured with
ClientHttpConnector
and ExchangeStrategies
.
This is an alternative to, and effectively overrides
clientConnector(org.springframework.http.client.reactive.ClientHttpConnector)
, and
exchangeStrategies(ExchangeStrategies)
.
exchangeFunction
- the exchange function to useWebClient.Builder apply(Consumer<WebClient.Builder> builderConsumer)
Consumer
to this builder instance.
This can be useful for applying pre-packaged customizations.
builderConsumer
- the consumer to applyWebClient.Builder clone()
WebClient.Builder
.