Class RestClientBuilder
java.lang.Object
org.springframework.vault.client.RestClientBuilder
Builder that can be used to configure and create a
RestClient
. Provides
convenience methods to configure ClientHttpRequestFactory
, error handlers
and default headers
.
By default, the built RestClient
will attempt to use the most suitable
ClientHttpRequestFactory
using ClientHttpRequestFactoryFactory.create(ClientOptions, SslConfiguration)
.
- Since:
- 4.0
- Author:
- Mark Paluch
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Build a newRestClient
.static RestClientBuilder
builder()
Create a newRestClientBuilder
.protected RestClient
Create theRestClient
to use.customizers
(RestClientCustomizer... customizer) Add theRestClientCustomizers
that should be applied to theRestClient
.defaultHeader
(String name, String value) Add a default header that will be set if not already present on the outgoingHttpRequest
.endpoint
(VaultEndpoint endpoint) Set theVaultEndpoint
that should be used with theRestClient
.endpointProvider
(VaultEndpointProvider provider) Set theVaultEndpointProvider
that should be used with theRestClient
.errorHandler
(ResponseErrorHandler errorHandler) Set theResponseErrorHandler
that should be used with theRestClient
.requestFactory
(Supplier<ClientHttpRequestFactory> requestFactory) Set theSupplier
ofClientHttpRequestFactory
that should be called each time webuild()
a newRestClient
instance.requestFactory
(ClientHttpRequestFactory requestFactory) Set theClientHttpRequestFactory
that should be used with theRestClient
.requestInitializers
(ClientHttpRequestInitializer... requestInitializer) Add theClientHttpRequestInitializers
that should be applied toClientHttpRequest
initialization.
-
Method Details
-
builder
Create a newRestClientBuilder
.- Returns:
- a new
RestClientBuilder
.
-
endpoint
Set theVaultEndpoint
that should be used with theRestClient
.- Parameters:
endpoint
- theVaultEndpoint
provider.- Returns:
this
RestClientBuilder
.
-
endpointProvider
Set theVaultEndpointProvider
that should be used with theRestClient
.- Parameters:
provider
- theVaultEndpoint
provider.- Returns:
this
RestClientBuilder
.
-
requestFactory
Set theClientHttpRequestFactory
that should be used with theRestClient
.- Parameters:
requestFactory
- the request factory.- Returns:
this
RestClientBuilder
.
-
requestFactory
Set theSupplier
ofClientHttpRequestFactory
that should be called each time webuild()
a newRestClient
instance.- Parameters:
requestFactory
- the supplier for the request factory.- Returns:
this
RestClientBuilder
.
-
errorHandler
Set theResponseErrorHandler
that should be used with theRestClient
.- Parameters:
errorHandler
- the error handler to use.- Returns:
this
RestClientBuilder
.
-
defaultHeader
Add a default header that will be set if not already present on the outgoingHttpRequest
.- Parameters:
name
- the name of the header.value
- the header value.- Returns:
this
RestClientBuilder
.
-
customizers
Add theRestClientCustomizers
that should be applied to theRestClient
. Customizers are applied in the order that they were added.- Parameters:
customizer
- the template customizers to add.- Returns:
this
RestClientBuilder
.
-
requestInitializers
Add theClientHttpRequestInitializers
that should be applied toClientHttpRequest
initialization. Customizers are applied in the order that they were added.- Parameters:
requestInitializer
- the request initializers to add.- Returns:
this
RestClientBuilder
.
-
build
Build a newRestClient
.VaultEndpoint
must be set.Applies also
ResponseErrorHandler
andRestTemplateCustomizer
if configured.- Returns:
- a new
RestClient
.
-
createClient
-