public class RestTemplateBuilder extends Object
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)
.ClientHttpRequestFactoryFactory
,
RestTemplateCustomizer
public static RestTemplateBuilder builder()
RestTemplateBuilder
.RestTemplateBuilder
.public RestTemplateBuilder endpoint(VaultEndpoint endpoint)
VaultEndpoint
that should be used with the RestTemplate
.endpoint
- the VaultEndpoint
provider.this
RestTemplateBuilder
.public RestTemplateBuilder endpointProvider(VaultEndpointProvider provider)
VaultEndpointProvider
that should be used with the
RestTemplate
.provider
- the VaultEndpoint
provider.this
RestTemplateBuilder
.public RestTemplateBuilder requestFactory(ClientHttpRequestFactory requestFactory)
ClientHttpRequestFactory
that should be used with the
RestTemplate
.requestFactory
- the request factory.this
RestTemplateBuilder
.public RestTemplateBuilder requestFactory(Supplier<ClientHttpRequestFactory> requestFactory)
Supplier
of ClientHttpRequestFactory
that should be called
each time we build()
a new RestTemplate
instance.requestFactory
- the supplier for the request factory.this
RestTemplateBuilder
.public RestTemplateBuilder errorHandler(ResponseErrorHandler errorHandler)
ResponseErrorHandler
that should be used with the
RestTemplate
.errorHandler
- the error handler to use.this
RestTemplateBuilder
.public RestTemplateBuilder defaultHeader(String name, String value)
HttpRequest
.name
- the name of the header.value
- the header value.this
RestTemplateBuilder
.public RestTemplateBuilder customizers(RestTemplateCustomizer... customizer)
RestTemplateCustomizers
that should be
applied to the RestTemplate
. Customizers are applied in the order that they
were added.customizer
- the template customizers to add.this
RestTemplateBuilder
.public RestTemplateBuilder requestCustomizers(RestTemplateRequestCustomizer<?>... requestCustomizers)
RestTemplateRequestCustomizers
that
should be applied to the ClientHttpRequest
. Customizers are applied in the
order that they were added.requestCustomizers
- the request customizers to add.this
RestTemplateBuilder
.public RestTemplate build()
RestTemplate
. VaultEndpoint
must be set.
Applies also ResponseErrorHandler
and RestTemplateCustomizer
if
configured.RestTemplate
.protected RestTemplate createTemplate()
RestTemplate
to use.RestTemplate
to use.Copyright © 2016–2021 Pivotal Software, Inc.. All rights reserved.