Package org.springframework.web.client
Interface RestClient
public interface RestClient
Client to perform HTTP requests, exposing a fluent, synchronous API over
 underlying HTTP client libraries such as 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:
- Since:
- 6.1
- Author:
- Arjen Poutsma, Sebastien Deleuze
- 
Nested Class SummaryNested ClassesModifier and TypeInterfaceDescriptionstatic 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.
- 
Method SummaryModifier and TypeMethodDescriptionstatic RestClient.Builderbuilder()Obtain aRestClientbuilder.static RestClient.Builderbuilder(RestTemplate restTemplate) Obtain aRestClientbuilder based on the configuration of the givenRestTemplate.static RestClientcreate()Create a newRestClient.static RestClientVariant ofcreate()that accepts a default base URL.static RestClientVariant ofcreate()that accepts a default baseURI.static RestClientcreate(RestTemplate restTemplate) Create a newRestClientbased on the configuration of the givenRestTemplate.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 thisRestClient.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.
- 
Method Details- 
getRestClient.RequestHeadersUriSpec<?> get()Start building an HTTP GET request.- Returns:
- a spec for specifying the target URL
 
- 
headRestClient.RequestHeadersUriSpec<?> head()Start building an HTTP HEAD request.- Returns:
- a spec for specifying the target URL
 
- 
postStart building an HTTP POST request.- Returns:
- a spec for specifying the target URL
 
- 
putStart building an HTTP PUT request.- Returns:
- a spec for specifying the target URL
 
- 
patchRestClient.RequestBodyUriSpec patch()Start building an HTTP PATCH request.- Returns:
- a spec for specifying the target URL
 
- 
deleteRestClient.RequestHeadersUriSpec<?> delete()Start building an HTTP DELETE request.- Returns:
- a spec for specifying the target URL
 
- 
optionsRestClient.RequestHeadersUriSpec<?> options()Start building an HTTP OPTIONS request.- Returns:
- a spec for specifying the target URL
 
- 
methodStart building a request for the givenHttpMethod.- Returns:
- a spec for specifying the target URL
 
- 
mutateRestClient.Builder mutate()Return a builder to create a newRestClientwhose settings are replicated from thisRestClient.
- 
createCreate a newRestClient.- See Also:
 
- 
createVariant ofcreate()that accepts a default base URL. For more details seeBuilder.baseUrl(String).- Parameters:
- baseUrl- the base URI for all requests
- See Also:
 
- 
create- Parameters:
- baseUrl- the base URI for all requests
- Since:
- 6.2
- See Also:
 
- 
createCreate a newRestClientbased on the configuration of the givenRestTemplate.The returned builder is configured with the following attributes of the template. - Parameters:
- restTemplate- the rest template to base the returned client's configuration on
- Returns:
- a RestClientinitialized with therestTemplate's configuration
 
- 
builderObtain aRestClientbuilder.
- 
builderObtain aRestClientbuilder based on the configuration of the givenRestTemplate.The returned builder is configured with the following attributes of the template. - Parameters:
- restTemplate- the rest template to base the returned builder's configuration on
- Returns:
- a RestClientbuilder initialized withrestTemplate's configuration
 
 
-