org.springframework.web.reactive.function.client

## Interface WebClient.Builder

Enclosing interface:
  WebClient

    public static interface WebClient.Builder

A mutable builder for creating a `WebClient`.

### Method Summary

All Methods Instance Methods Abstract Methods Deprecated Methods
`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(org.springframework.http.client.reactive.ClientHttpConnector connector)` Configure the `ClientHttpConnector` to use.
`WebClient.Builder` `clone()` Clone this `WebClient.Builder`.
`WebClient.Builder` `codecs(Consumer<org.springframework.http.codec.ClientCodecConfigurer> configurer)` Configure the codecs for the `WebClient` in the `underlying` `ExchangeStrategies`.
`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<org.springframework.util.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<org.springframework.http.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 modify every request being built just before the call to `exchange()`.
`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)` Provide an `ExchangeFunction` pre-configured with `ClientHttpConnector` and `ExchangeStrategies`.
`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(org.springframework.web.util.UriBuilderFactory uriBuilderFactory)` Provide a pre-configured `UriBuilderFactory` instance.

### Method Detail

#### baseUrl

    WebClient.Builder baseUrl(String baseUrl)

Configure 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 `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.

See Also:
  `DefaultUriBuilderFactory.DefaultUriBuilderFactory(String)`, `uriBuilderFactory(UriBuilderFactory)`

#### defaultUriVariables

    WebClient.Builder defaultUriVariables(Map<String,?> defaultUriVariables)

Configure default URL variable values to use when expanding URI templates with a `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.

See Also:
  `DefaultUriBuilderFactory.setDefaultUriVariables(Map)`, `uriBuilderFactory(UriBuilderFactory)`

#### uriBuilderFactory

    WebClient.Builder uriBuilderFactory(org.springframework.web.util.UriBuilderFactory uriBuilderFactory)

Provide a pre-configured `UriBuilderFactory` instance. This is an alternative to, and effectively overrides the following shortcut properties:

- `baseUrl(String)`
- `defaultUriVariables(Map)`.

Parameters:
  `uriBuilderFactory` - the URI builder factory to use
See Also:
  `baseUrl(String)`, `defaultUriVariables(Map)`

#### defaultHeader

    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.

Parameters:
  `header` - the header name
  `values` - the header values

#### defaultHeaders

    WebClient.Builder defaultHeaders(Consumer<org.springframework.http.HttpHeaders> headersConsumer)

Provides access to every `defaultHeader(String, String...)` declared so far with the possibility to add, replace, or remove.

Parameters:
  `headersConsumer` - the consumer

#### defaultCookie

    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.

Parameters:
  `cookie` - the cookie name
  `values` - the cookie values

#### defaultCookies

    WebClient.Builder defaultCookies(Consumer<org.springframework.util.MultiValueMap<String,String>> cookiesConsumer)

Provides access to every `defaultCookie(String, String...)` declared so far with the possibility to add, replace, or remove.

Parameters:
  `cookiesConsumer` - a function that consumes the cookies map

#### defaultRequest

    WebClient.Builder defaultRequest(Consumer<WebClient.RequestHeadersSpec<?>> defaultRequest)

Provide a consumer to modify every request being built just before the call to `exchange()`.

Parameters:
  `defaultRequest` - the consumer to use for modifying requests
Since:
  5.1

#### filter

    WebClient.Builder filter(ExchangeFilterFunction filter)

Add the given filter to the end of the filter chain.

Parameters:
  `filter` - the filter to be added to the chain

#### filters

    WebClient.Builder filters(Consumer<List<ExchangeFilterFunction>> filtersConsumer)

Manipulate 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

#### clientConnector

    WebClient.Builder clientConnector(org.springframework.http.client.reactive.ClientHttpConnector connector)

Configure the `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`.

Parameters:
  `connector` - the connector to use

#### codecs

    WebClient.Builder codecs(Consumer<org.springframework.http.codec.ClientCodecConfigurer> configurer)

Configure the codecs for the `WebClient` in the `underlying` `ExchangeStrategies`.

Parameters:
  `configurer` - the configurer to apply
Since:
  5.1.13

#### exchangeStrategies

    WebClient.Builder exchangeStrategies(ExchangeStrategies strategies)

Configure the `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()`.

Parameters:
  `strategies` - the strategies to use

#### exchangeStrategies

    @Deprecated
    WebClient.Builder exchangeStrategies(Consumer<ExchangeStrategies.Builder> configurer)

Deprecated. as of 5.1.13 in favor of `codecs(Consumer)`
Customize the strategies configured via `exchangeStrategies(ExchangeStrategies)`. This method is designed for use in scenarios where multiple parties wish to update the `ExchangeStrategies`.

#### exchangeFunction

    WebClient.Builder exchangeFunction(ExchangeFunction exchangeFunction)

Provide an `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)`.

Parameters:
  `exchangeFunction` - the exchange function to use

#### apply

    WebClient.Builder apply(Consumer<WebClient.Builder> builderConsumer)

Apply the given `Consumer` to this builder instance.

This can be useful for applying pre-packaged customizations.

Parameters:
  `builderConsumer` - the consumer to apply

#### clone

    WebClient.Builder clone()

Clone this `WebClient.Builder`.

#### build

    WebClient build()

Builder the `WebClient` instance.