接口 RestClient
- 所有已知实现类:
DefaultRestClient
public interface RestClient
Client to perform HTTP requests, exposing a fluent, synchronous API over
underlying HTTP client libraries such the JDK
HttpClient, Apache
HttpComponents, and others.
Use static factory methods create(), create(String),
or builder() to prepare an instance. To use the same
configuration as a RestTemplate, use create(RestTemplate) or
builder(RestTemplate).
For examples with a response body see:
For examples with a request body see:
- 从以下版本开始:
- 4.0
- 作者:
- Arjen Poutsma, Harry Yang
-
嵌套类概要
嵌套类修饰符和类型接口说明static interfaceA mutable builder for creating aRestClient.static interfaceContract for specifying request headers and body leading up to the exchange.static interfaceContract for specifying request headers, body and URI for a request.static interfaceContract for specifying request headers leading up to the exchange.static interfaceContract for specifying request headers and URI for a request.static interfaceContract for specifying response operations following the exchange.static interfaceRestClient.UriSpec<S extends RestClient.RequestHeadersSpec<?>>Contract for specifying the URI for a request. -
方法概要
修饰符和类型方法说明static RestClient.Builderbuilder()Obtain aRestClientbuilder.static RestClient.Builderbuilder(RestTemplate restTemplate) Obtain aRestClientbuilder based on the configuration of the givenRestTemplate.static RestClientcreate()Create a newRestClient.static RestClientcreate(RestTemplate restTemplate) Create a newRestClientbased on the configuration of the givenRestTemplate.static RestClientVariant ofcreate()that accepts a default base URL.delete()Start building an HTTP DELETE request.get()Start building an HTTP GET request.head()Start building an HTTP HEAD request.method(HttpMethod method) Start building a request for the givenHttpMethod.mutate()Return a builder to create a newRestClientwhose settings are replicated from the currentRestClient.options()Start building an HTTP OPTIONS request.patch()Start building an HTTP PATCH request.post()Start building an HTTP POST request.put()Start building an HTTP PUT request.
-
方法详细资料
-
get
RestClient.RequestHeadersUriSpec<?> get()Start building an HTTP GET request.- 返回:
- a spec for specifying the target URL
-
head
RestClient.RequestHeadersUriSpec<?> head()Start building an HTTP HEAD request.- 返回:
- a spec for specifying the target URL
-
post
Start building an HTTP POST request.- 返回:
- a spec for specifying the target URL
-
put
Start building an HTTP PUT request.- 返回:
- a spec for specifying the target URL
-
patch
RestClient.RequestBodyUriSpec patch()Start building an HTTP PATCH request.- 返回:
- a spec for specifying the target URL
-
delete
RestClient.RequestBodyUriSpec delete()Start building an HTTP DELETE request.- 返回:
- a spec for specifying the target URL
-
options
RestClient.RequestHeadersUriSpec<?> options()Start building an HTTP OPTIONS request.- 返回:
- a spec for specifying the target URL
-
method
Start building a request for the givenHttpMethod.- 返回:
- a spec for specifying the target URL
-
mutate
RestClient.Builder mutate()Return a builder to create a newRestClientwhose settings are replicated from the currentRestClient. -
create
Create a newRestClient.- 另请参阅:
-
create
Variant ofcreate()that accepts a default base URL. For more details seeBuilder.baseUrl(String).- 参数:
baseUrl- the base URI for all requests- 另请参阅:
-
create
Create a newRestClientbased on the configuration of the givenRestTemplate. The returned builder is configured with the template's- 参数:
restTemplate- the rest template to base the returned client's configuration on- 返回:
- a
RestClientinitialized with therestTemplate's configuration
-
builder
Obtain aRestClientbuilder. -
builder
Obtain aRestClientbuilder based on the configuration of the givenRestTemplate. The returned builder is configured with the template's- 参数:
restTemplate- the rest template to base the returned builder's configuration on- 返回:
- a
RestClientbuilder initialized withrestTemplate's configuration
-