Interface WebClient
public interface WebClient
Non-blocking, reactive client to perform HTTP requests, exposing a fluent,
reactive API over underlying HTTP client libraries such as Reactor Netty.
Use static factory methods create() or create(String),
or builder() to prepare an instance.
For examples with a response body see:
For examples with a request body see:
- Since:
- 5.0
- Author:
- Rossen Stoyanchev, Arjen Poutsma, Sebastien Deleuze, Brian Clozel
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceA mutable builder for creating aWebClient.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 interfaceWebClient.UriSpec<S extends WebClient.RequestHeadersSpec<?>>Contract for specifying the URI for a request. -
Method Summary
Modifier and TypeMethodDescriptionstatic WebClient.Builderbuilder()Obtain aWebClientbuilder.static WebClientcreate()Create a newWebClientwith Reactor Netty by default.static WebClientVariant 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 newWebClientwhose settings are replicated from the currentWebClient.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
-
get
WebClient.RequestHeadersUriSpec<?> get()Start building an HTTP GET request.- Returns:
- a spec for specifying the target URL
-
head
WebClient.RequestHeadersUriSpec<?> head()Start building an HTTP HEAD request.- Returns:
- a spec for specifying the target URL
-
post
WebClient.RequestBodyUriSpec post()Start building an HTTP POST request.- Returns:
- a spec for specifying the target URL
-
put
Start building an HTTP PUT request.- Returns:
- a spec for specifying the target URL
-
patch
WebClient.RequestBodyUriSpec patch()Start building an HTTP PATCH request.- Returns:
- a spec for specifying the target URL
-
delete
WebClient.RequestHeadersUriSpec<?> delete()Start building an HTTP DELETE request.- Returns:
- a spec for specifying the target URL
-
options
WebClient.RequestHeadersUriSpec<?> options()Start building an HTTP OPTIONS request.- Returns:
- a spec for specifying the target URL
-
method
Start building a request for the givenHttpMethod.- Returns:
- a spec for specifying the target URL
-
mutate
WebClient.Builder mutate()Return a builder to create a newWebClientwhose settings are replicated from the currentWebClient. -
create
Create a newWebClientwith Reactor Netty by default.- See Also:
-
create
Variant ofcreate()that accepts a default base URL. For more details seeBuilder.baseUrl(String).- Parameters:
baseUrl- the base URI for all requests- See Also:
-
builder
Obtain aWebClientbuilder.
-