类 DefaultRestClientBuilder
- 所有已实现的接口:
RestClient.Builder
RestClient.Builder.- 从以下版本开始:
- 4.0
- 作者:
- Arjen Poutsma, Harry Yang
-
字段概要
字段修饰符和类型字段说明private Stringprivate HttpHeadersprivate Consumer<RestClient.RequestHeadersSpec<?>>private static final booleanprivate static final booleanprivate List<ClientHttpRequestInitializer>private List<ClientHttpRequestInterceptor>private static final booleanprivate static final booleanprivate static final booleanprivate static final booleanprivate static final booleanprivate static final booleanprivate List<HttpMessageConverter<?>>private ClientHttpRequestFactoryprivate List<StatusHandler>private UriBuilderFactory -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明apply(Consumer<RestClient.Builder> builderConsumer) Apply the givenConsumerto this builder instance.Configure a base URL for requests.build()Build theRestClientinstance.clone()Clone thisRestClient.Builder.private HttpHeadersdefaultHeader(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.defaultHeaders(Consumer<HttpHeaders> headersConsumer) Provide a consumer to access to every default header declared so far, with the possibility to add, replace, or remove.defaultRequest(Consumer<RestClient.RequestHeadersSpec<?>> defaultRequest) Provide a consumer to customize every request being built.defaultStatusHandler(ResponseErrorHandler errorHandler) Register a default status handler to apply to every response.defaultStatusHandler(Predicate<HttpStatusCode> statusPredicate, RestClient.ResponseSpec.ErrorHandler errorHandler) Register a default status handler to apply to every response.private RestClient.BuilderdefaultStatusHandlerInternal(StatusHandler statusHandler) defaultUriVariables(Map<String, ?> defaultUriVariables) Configure default URL variable values to use when expanding URI templates with aMap.private HttpHeadersprivate List<ClientHttpRequestInitializer>private List<ClientHttpRequestInterceptor>private List<HttpMessageConverter<?>>private ClientHttpRequestFactoryprivate UriBuilderFactorymessageConverters(Consumer<List<HttpMessageConverter<?>>> configurer) Configure the message converters for theRestClientto use.requestFactory(ClientHttpRequestFactory requestFactory) Configure theClientHttpRequestFactoryto use.requestInitializer(ClientHttpRequestInitializer initializer) Add the given request initializer to the end of the initializer chain.requestInitializers(Consumer<List<ClientHttpRequestInitializer>> initializersConsumer) Manipulate the initializers with the given consumer.requestInterceptor(ClientHttpRequestInterceptor interceptor) Add the given request interceptor to the end of the interceptor chain.requestInterceptors(Consumer<List<ClientHttpRequestInterceptor>> interceptorsConsumer) Manipulate the interceptors with the given consumer.uriBuilderFactory(UriBuilderFactory uriBuilderFactory) Provide a pre-configuredUriBuilderFactoryinstance.
-
字段详细资料
-
httpComponentsClientPresent
private static final boolean httpComponentsClientPresent -
jettyClientPresent
private static final boolean jettyClientPresent -
jdkClientPresent
private static final boolean jdkClientPresent -
jackson2Present
private static final boolean jackson2Present -
gsonPresent
private static final boolean gsonPresent -
jsonbPresent
private static final boolean jsonbPresent -
jackson2SmilePresent
private static final boolean jackson2SmilePresent -
jackson2CborPresent
private static final boolean jackson2CborPresent -
baseUrl
-
defaultUriVariables
-
uriBuilderFactory
-
defaultHeaders
-
defaultRequest
-
statusHandlers
-
requestFactory
-
messageConverters
-
interceptors
-
initializers
-
-
构造器详细资料
-
DefaultRestClientBuilder
public DefaultRestClientBuilder() -
DefaultRestClientBuilder
-
DefaultRestClientBuilder
-
-
方法详细资料
-
baseUrl
从接口复制的说明:RestClient.BuilderConfigure a base URL for requests. Effectively a shortcut for:String baseUrl = "https://abc.go.com/v1"; DefaultUriBuilderFactory factory = new DefaultUriBuilderFactory(baseUrl); RestClient client = RestClient.builder().uriBuilderFactory(factory).build();The
DefaultUriBuilderFactoryis 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
RestClient.Builder.uriBuilderFactory(UriBuilderFactory). If both are used, thebaseUrlvalue provided here will be ignored.- 指定者:
baseUrl在接口中RestClient.Builder- 返回:
- this builder
- 另请参阅:
-
defaultUriVariables
从接口复制的说明:RestClient.BuilderConfigure default URL variable values to use when expanding URI templates with aMap. Effectively a shortcut for:Map<String, ?> defaultVars = ...; DefaultUriBuilderFactory factory = new DefaultUriBuilderFactory(); factory.setDefaultVariables(defaultVars); RestClient client = RestClient.builder().uriBuilderFactory(factory).build();Note: this method is mutually exclusive with
RestClient.Builder.uriBuilderFactory(UriBuilderFactory). If both are used, thedefaultUriVariablesvalue provided here will be ignored.- 指定者:
defaultUriVariables在接口中RestClient.Builder- 返回:
- this builder
- 另请参阅:
-
uriBuilderFactory
从接口复制的说明:RestClient.BuilderProvide a pre-configuredUriBuilderFactoryinstance. This is an alternative to, and effectively overrides the following shortcut properties:- 指定者:
uriBuilderFactory在接口中RestClient.Builder- 参数:
uriBuilderFactory- the URI builder factory to use- 返回:
- this builder
- 另请参阅:
-
defaultHeader
从接口复制的说明:RestClient.BuilderGlobal option to specify a header to be added to every request, if the request does not already contain such a header.- 指定者:
defaultHeader在接口中RestClient.Builder- 参数:
header- the header namevalues- the header values- 返回:
- this builder
-
defaultHeaders
从接口复制的说明:RestClient.BuilderProvide a consumer to access to every default header declared so far, with the possibility to add, replace, or remove.- 指定者:
defaultHeaders在接口中RestClient.Builder- 参数:
headersConsumer- the consumer- 返回:
- this builder
-
initHeaders
-
defaultRequest
从接口复制的说明:RestClient.BuilderProvide a consumer to customize every request being built.- 指定者:
defaultRequest在接口中RestClient.Builder- 参数:
defaultRequest- the consumer to use for modifying requests- 返回:
- this builder
-
defaultStatusHandler
public RestClient.Builder defaultStatusHandler(Predicate<HttpStatusCode> statusPredicate, RestClient.ResponseSpec.ErrorHandler errorHandler) 从接口复制的说明:RestClient.BuilderRegister a default status handler to apply to every response. Such default handlers are applied in the order in which they are registered, and after any others that are registered for a specific response.- 指定者:
defaultStatusHandler在接口中RestClient.Builder- 参数:
statusPredicate- to match responses witherrorHandler- handler that typically, though not necessarily, throws an exception- 返回:
- this builder
-
defaultStatusHandler
从接口复制的说明:RestClient.BuilderRegister a default status handler to apply to every response. Such default handlers are applied in the order in which they are registered, and after any others that are registered for a specific response.- 指定者:
defaultStatusHandler在接口中RestClient.Builder- 参数:
errorHandler- handler that typically, though not necessarily, throws an exception- 返回:
- this builder
-
defaultStatusHandlerInternal
-
requestInterceptor
从接口复制的说明:RestClient.BuilderAdd the given request interceptor to the end of the interceptor chain.- 指定者:
requestInterceptor在接口中RestClient.Builder- 参数:
interceptor- the interceptor to be added to the chain- 返回:
- this builder
-
requestInterceptors
public RestClient.Builder requestInterceptors(Consumer<List<ClientHttpRequestInterceptor>> interceptorsConsumer) 从接口复制的说明:RestClient.BuilderManipulate the interceptors with the given consumer. The list provided to the consumer is "live", so that the consumer can be used to remove interceptors, change ordering, etc.- 指定者:
requestInterceptors在接口中RestClient.Builder- 参数:
interceptorsConsumer- a function that consumes the interceptors list- 返回:
- this builder
-
initInterceptors
-
requestInitializer
从接口复制的说明:RestClient.BuilderAdd the given request initializer to the end of the initializer chain.- 指定者:
requestInitializer在接口中RestClient.Builder- 参数:
initializer- the initializer to be added to the chain- 返回:
- this builder
-
requestInitializers
public RestClient.Builder requestInitializers(Consumer<List<ClientHttpRequestInitializer>> initializersConsumer) 从接口复制的说明:RestClient.BuilderManipulate the initializers with the given consumer. The list provided to the consumer is "live", so that the consumer can be used to remove initializers, change ordering, etc.- 指定者:
requestInitializers在接口中RestClient.Builder- 参数:
initializersConsumer- a function that consumes the initializers list- 返回:
- this builder
-
initInitializers
-
requestFactory
从接口复制的说明:RestClient.BuilderConfigure theClientHttpRequestFactoryto use. This is useful for plugging in and/or customizing options of the underlying HTTP client library (e.g. SSL).If no request factory is specified,
RestClientuses Apache Http Client, Jetty Http Client if available on the classpath, and defaults to the JDK HttpClient if thejava.net.httpmodule is loaded, or to a simple default otherwise.- 指定者:
requestFactory在接口中RestClient.Builder- 参数:
requestFactory- the request factory to use- 返回:
- this builder
-
messageConverters
从接口复制的说明:RestClient.BuilderConfigure the message converters for theRestClientto use.- 指定者:
messageConverters在接口中RestClient.Builder- 参数:
configurer- the configurer to apply- 返回:
- this builder
-
apply
从接口复制的说明:RestClient.BuilderApply the givenConsumerto this builder instance.This can be useful for applying pre-packaged customizations.
- 指定者:
apply在接口中RestClient.Builder- 参数:
builderConsumer- the consumer to apply- 返回:
- this builder
-
initMessageConverters
-
clone
从接口复制的说明:RestClient.BuilderClone thisRestClient.Builder.- 指定者:
clone在接口中RestClient.Builder- 覆盖:
clone在类中Object
-
build
从接口复制的说明:RestClient.BuilderBuild theRestClientinstance.- 指定者:
build在接口中RestClient.Builder
-
initRequestFactory
-
initUriBuilderFactory
-
copyDefaultHeaders
-