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 interface A mutable builder for creating aWebClient.static interface Contract for specifying request headers and body leading up to the exchange.static interface Contract for specifying request headers, body and URI for a request.static interface Contract for specifying request headers leading up to the exchange.static interface Contract for specifying request headers and URI for a request.static interface Contract for specifying response operations following the exchange.static interface WebClient.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
WebClient.RequestBodyUrispec 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
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.
-