Top Description Inners Methods
org.springframework.web.client

public Interface RestClient

Known Direct Implementers
org.springframework.web.client.DefaultRestClient
Imports
java.io.IOException, .OutputStream, java.net.URI, java.nio.charset.Charset, java.time.ZonedDateTime, java.util.List, .Map, java.util.function.Consumer, .Function, .Predicate, io.micrometer.observation.ObservationRegistry, org.springframework.core.ParameterizedTypeReference, org.springframework.http.HttpHeaders, .HttpMethod, .HttpRequest, .HttpStatusCode, .MediaType, .ResponseEntity, .StreamingHttpOutputMessage, org.springframework.http.client.ClientHttpRequest, .ClientHttpRequestFactory, .ClientHttpRequestInitializer, .ClientHttpRequestInterceptor, .ClientHttpResponse, org.springframework.http.client.observation.ClientRequestObservationConvention, org.springframework.http.converter.HttpMessageConverter, org.springframework.lang.Nullable, org.springframework.web.util.DefaultUriBuilderFactory, .UriBuilder, .UriBuilderFactory

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 RestClient#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:

Author
Arjen Poutsma
Since
6.1

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
RestClient.Builder

A mutable builder for creating a RestClient.

public static interface
RestClient.RequestBodySpec

Contract for specifying request headers and body leading up to the exchange.

public static interface
RestClient.RequestBodyUriSpec

Contract for specifying request headers, body and URI for a request.

public static interface
RestClient.RequestHeadersSpec<
a self reference to the spec type
S extends RestClient.RequestHeadersSpec<S>
>

Contract for specifying request headers leading up to the exchange.

public static interface
RestClient.RequestHeadersUriSpec<
a self reference to the spec type
S extends RestClient.RequestHeadersSpec<S>
>

Contract for specifying request headers and URI for a request.

public static interface
RestClient.ResponseSpec

Contract for specifying response operations following the exchange.

public static interface
RestClient.UriSpec<
a self reference to the spec type
S extends RestClient.RequestHeadersSpec<?>
>

Contract for specifying the URI for a request.

Method Summary

Modifier and TypeMethod and Description
public static RestClient.Builder
builder()

Obtain a RestClient builder.

public static RestClient.Builder

Returns:

a RestClient builder initialized with restTemplate's configuration
builder
(RestTemplate
the rest template to base the returned builder's configuration on
restTemplate
)

Obtain a RestClient builder based on the configuration of the given RestTemplate.

public static RestClient
create()

Create a new RestClient.

public static RestClient
create(String
the base URI for all requests
baseUrl
)

Variant of create() that accepts a default base URL.

public static RestClient

Returns:

a RestClient initialized with the restTemplate's configuration
create
(RestTemplate
the rest template to base the returned client's configuration on
restTemplate
)

Create a new RestClient based on the configuration of the given RestTemplate.

public RestClient.RequestHeadersUriSpec<?>

Returns:

a spec for specifying the target URL
delete
()

Start building an HTTP DELETE request.

public RestClient.RequestHeadersUriSpec<?>

Returns:

a spec for specifying the target URL
get
()

Start building an HTTP GET request.

public RestClient.RequestHeadersUriSpec<?>

Returns:

a spec for specifying the target URL
head
()

Start building an HTTP HEAD request.

public RestClient.RequestBodyUriSpec

Returns:

a spec for specifying the target URL
method
(HttpMethod method)

Start building a request for the given HttpMethod.

public RestClient.Builder
mutate()

Return a builder to create a new RestClient whose settings are replicated from this RestClient.

public RestClient.RequestHeadersUriSpec<?>

Returns:

a spec for specifying the target URL
options
()

Start building an HTTP OPTIONS request.

public RestClient.RequestBodyUriSpec

Returns:

a spec for specifying the target URL
patch
()

Start building an HTTP PATCH request.

public RestClient.RequestBodyUriSpec

Returns:

a spec for specifying the target URL
post
()

Start building an HTTP POST request.

public RestClient.RequestBodyUriSpec

Returns:

a spec for specifying the target URL
put
()

Start building an HTTP PUT request.