Package org.springframework.vault.client
Class RestTemplateBuilder
java.lang.Object
org.springframework.vault.client.RestTemplateBuilder
Builder that can be used to configure and create a
RestTemplate. Provides
convenience methods to configure ClientHttpRequestFactory, error handlers
and default headers.
By default the built RestTemplate will attempt to use the most suitable
ClientHttpRequestFactory using ClientHttpRequestFactoryFactory.create(org.springframework.vault.support.ClientOptions, org.springframework.vault.support.SslConfiguration).- Since:
- 2.2
- Author:
- Mark Paluch
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbuild()Build a newRestTemplate.static RestTemplateBuilderbuilder()Create a newRestTemplateBuilder.protected RestTemplateCreate theRestTemplateto use.customizers(RestTemplateCustomizer... customizer) Add theRestTemplateCustomizersthat should be applied to theRestTemplate.defaultHeader(String name, String value) Add a default header that will be set if not already present on the outgoingHttpRequest.endpoint(VaultEndpoint endpoint) Set theVaultEndpointthat should be used with theRestTemplate.endpointProvider(VaultEndpointProvider provider) Set theVaultEndpointProviderthat should be used with theRestTemplate.errorHandler(ResponseErrorHandler errorHandler) Set theResponseErrorHandlerthat should be used with theRestTemplate.requestCustomizers(RestTemplateRequestCustomizer<?>... requestCustomizers) Add theRestTemplateRequestCustomizersthat should be applied to theClientHttpRequest.requestFactory(Supplier<ClientHttpRequestFactory> requestFactory) Set theSupplierofClientHttpRequestFactorythat should be called each time webuild()a newRestTemplateinstance.requestFactory(ClientHttpRequestFactory requestFactory) Set theClientHttpRequestFactorythat should be used with theRestTemplate.
-
Method Details
-
builder
Create a newRestTemplateBuilder.- Returns:
- a new
RestTemplateBuilder.
-
endpoint
Set theVaultEndpointthat should be used with theRestTemplate.- Parameters:
endpoint- theVaultEndpointprovider.- Returns:
thisRestTemplateBuilder.
-
endpointProvider
Set theVaultEndpointProviderthat should be used with theRestTemplate.- Parameters:
provider- theVaultEndpointprovider.- Returns:
thisRestTemplateBuilder.
-
requestFactory
Set theClientHttpRequestFactorythat should be used with theRestTemplate.- Parameters:
requestFactory- the request factory.- Returns:
thisRestTemplateBuilder.
-
requestFactory
Set theSupplierofClientHttpRequestFactorythat should be called each time webuild()a newRestTemplateinstance.- Parameters:
requestFactory- the supplier for the request factory.- Returns:
thisRestTemplateBuilder.
-
errorHandler
Set theResponseErrorHandlerthat should be used with theRestTemplate.- Parameters:
errorHandler- the error handler to use.- Returns:
thisRestTemplateBuilder.
-
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:
thisRestTemplateBuilder.
-
customizers
Add theRestTemplateCustomizersthat should be applied to theRestTemplate. Customizers are applied in the order that they were added.- Parameters:
customizer- the template customizers to add.- Returns:
thisRestTemplateBuilder.
-
requestCustomizers
public RestTemplateBuilder requestCustomizers(RestTemplateRequestCustomizer<?>... requestCustomizers) Add theRestTemplateRequestCustomizersthat should be applied to theClientHttpRequest. Customizers are applied in the order that they were added.- Parameters:
requestCustomizers- the request customizers to add.- Returns:
thisRestTemplateBuilder.
-
build
Build a newRestTemplate.VaultEndpointmust be set. Applies alsoResponseErrorHandlerandRestTemplateCustomizerif configured.- Returns:
- a new
RestTemplate.
-
createTemplate
Create theRestTemplateto use.- Returns:
- the
RestTemplateto use.
-