Class WebClientAdapter
java.lang.Object
org.springframework.web.reactive.function.client.support.WebClientAdapter
- All Implemented Interfaces:
HttpClientAdapter
HttpClientAdapter
that enables an HttpServiceProxyFactory
to
use WebClient
for request execution.
Use static factory methods in this class to create an
HttpServiceProxyFactory
configured with a given WebClient
.
- Since:
- 6.0
- Author:
- Rossen Stoyanchev
-
Method Summary
Modifier and TypeMethodDescriptionstatic HttpServiceProxyFactory
createHttpServiceProxyFactory
(WebClient webClient) Static method to create aHttpServiceProxyFactory
configured to use the givenWebClient
instance.static HttpServiceProxyFactory
createHttpServiceProxyFactory
(WebClient.Builder webClientBuilder) Variant ofcreateHttpServiceProxyFactory(WebClient)
that accepts aWebClient.Builder
and uses it to create the client.static WebClientAdapter
Create aWebClientAdapter
for the givenWebClient
instance.reactor.core.publisher.Mono<ResponseEntity<Void>>
requestToBodilessEntity
(HttpRequestValues requestValues) Variant ofHttpClientAdapter.requestToVoid(HttpRequestValues)
with additional access to the response status and headers.<T> reactor.core.publisher.Mono<T>
requestToBody
(HttpRequestValues requestValues, ParameterizedTypeReference<T> bodyType) Perform the given request and decode the response content to the given type.<T> reactor.core.publisher.Flux<T>
requestToBodyFlux
(HttpRequestValues requestValues, ParameterizedTypeReference<T> bodyType) Perform the given request and decode the response content to a stream with elements of the given type.<T> reactor.core.publisher.Mono<ResponseEntity<T>>
requestToEntity
(HttpRequestValues requestValues, ParameterizedTypeReference<T> bodyType) Variant ofHttpClientAdapter.requestToBody(HttpRequestValues, ParameterizedTypeReference)
with additional access to the response status and headers.<T> reactor.core.publisher.Mono<ResponseEntity<reactor.core.publisher.Flux<T>>>
requestToEntityFlux
(HttpRequestValues requestValues, ParameterizedTypeReference<T> bodyType) Variant ofHttpClientAdapter.requestToBodyFlux(HttpRequestValues, ParameterizedTypeReference)
with additional access to the response status and headers.reactor.core.publisher.Mono<HttpHeaders>
requestToHeaders
(HttpRequestValues requestValues) Perform the given request, release the response content, and return the response headers.reactor.core.publisher.Mono<Void>
requestToVoid
(HttpRequestValues requestValues) Perform the given request, and release the response content, if any.
-
Method Details
-
requestToVoid
Description copied from interface:HttpClientAdapter
Perform the given request, and release the response content, if any.- Specified by:
requestToVoid
in interfaceHttpClientAdapter
- Parameters:
requestValues
- the request to perform- Returns:
Mono
that completes when the request is fully executed and the response content is released.
-
requestToHeaders
Description copied from interface:HttpClientAdapter
Perform the given request, release the response content, and return the response headers.- Specified by:
requestToHeaders
in interfaceHttpClientAdapter
- Parameters:
requestValues
- the request to perform- Returns:
Mono
that returns the response headers the request is fully executed and the response content released.
-
requestToBody
public <T> reactor.core.publisher.Mono<T> requestToBody(HttpRequestValues requestValues, ParameterizedTypeReference<T> bodyType) Description copied from interface:HttpClientAdapter
Perform the given request and decode the response content to the given type.- Specified by:
requestToBody
in interfaceHttpClientAdapter
- Type Parameters:
T
- the type the response is decoded to- Parameters:
requestValues
- the request to performbodyType
- the target type to decode to- Returns:
Mono
that returns the decoded response.
-
requestToBodyFlux
public <T> reactor.core.publisher.Flux<T> requestToBodyFlux(HttpRequestValues requestValues, ParameterizedTypeReference<T> bodyType) Description copied from interface:HttpClientAdapter
Perform the given request and decode the response content to a stream with elements of the given type.- Specified by:
requestToBodyFlux
in interfaceHttpClientAdapter
- Type Parameters:
T
- the type the response is decoded to- Parameters:
requestValues
- the request to performbodyType
- the target stream element type to decode to- Returns:
Flux
with decoded stream elements.
-
requestToBodilessEntity
public reactor.core.publisher.Mono<ResponseEntity<Void>> requestToBodilessEntity(HttpRequestValues requestValues) Description copied from interface:HttpClientAdapter
Variant ofHttpClientAdapter.requestToVoid(HttpRequestValues)
with additional access to the response status and headers.- Specified by:
requestToBodilessEntity
in interfaceHttpClientAdapter
-
requestToEntity
public <T> reactor.core.publisher.Mono<ResponseEntity<T>> requestToEntity(HttpRequestValues requestValues, ParameterizedTypeReference<T> bodyType) Description copied from interface:HttpClientAdapter
Variant ofHttpClientAdapter.requestToBody(HttpRequestValues, ParameterizedTypeReference)
with additional access to the response status and headers.- Specified by:
requestToEntity
in interfaceHttpClientAdapter
-
requestToEntityFlux
public <T> reactor.core.publisher.Mono<ResponseEntity<reactor.core.publisher.Flux<T>>> requestToEntityFlux(HttpRequestValues requestValues, ParameterizedTypeReference<T> bodyType) Description copied from interface:HttpClientAdapter
Variant ofHttpClientAdapter.requestToBodyFlux(HttpRequestValues, ParameterizedTypeReference)
with additional access to the response status and headers.- Specified by:
requestToEntityFlux
in interfaceHttpClientAdapter
-
createHttpServiceProxyFactory
Static method to create aHttpServiceProxyFactory
configured to use the givenWebClient
instance. Effectively a shortcut for:WebClientAdapter adapter = WebClientAdapter.forClient(webClient); HttpServiceProxyFactory proxyFactory = new HttpServiceProxyFactory(adapter);
- Parameters:
webClient
- the client to use- Returns:
- the created
HttpServiceProxyFactory
instance
-
createHttpServiceProxyFactory
public static HttpServiceProxyFactory createHttpServiceProxyFactory(WebClient.Builder webClientBuilder) Variant ofcreateHttpServiceProxyFactory(WebClient)
that accepts aWebClient.Builder
and uses it to create the client.- Parameters:
webClientBuilder
- a builder to create the client to use with- Returns:
- the created
HttpServiceProxyFactory
instance
-
forClient
Create aWebClientAdapter
for the givenWebClient
instance.- Parameters:
webClient
- the client to use- Returns:
- the created adapter instance
-