private static class DefaultWebClient.DefaultResponseSpec extends java.lang.Object implements WebClient.ResponseSpec
Modifier and Type | Class and Description |
---|---|
private static class |
DefaultWebClient.DefaultResponseSpec.StatusHandler |
Modifier and Type | Field and Description |
---|---|
private static DefaultWebClient.DefaultResponseSpec.StatusHandler |
DEFAULT_STATUS_HANDLER |
private <any> |
responseMono |
private java.util.List<DefaultWebClient.DefaultResponseSpec.StatusHandler> |
statusHandlers |
Constructor and Description |
---|
DefaultResponseSpec(<any> responseMono) |
Modifier and Type | Method and Description |
---|---|
<T> <any> |
bodyToFlux(java.lang.Class<T> elementType)
Extract the body to a
Flux . |
<T> <any> |
bodyToFlux(ParameterizedTypeReference<T> typeReference)
Extract the body to a
Flux . |
<T> <any> |
bodyToMono(java.lang.Class<T> bodyType)
Extract the body to a
Mono . |
<T> <any> |
bodyToMono(ParameterizedTypeReference<T> typeReference)
Extract the body to a
Mono . |
private <T extends <any>> |
bodyToPublisher(ClientResponse response,
BodyExtractor<T,? super ClientHttpResponse> extractor,
java.util.function.Function<<any>,T> errorFunction) |
private static <any> |
createResponseException(ClientResponse response) |
private <T> <any> |
monoThrowableToFlux(<any> mono) |
private <T> <any> |
monoThrowableToMono(<any> mono) |
WebClient.ResponseSpec |
onStatus(java.util.function.Predicate<HttpStatus> statusPredicate,
java.util.function.Function<ClientResponse,<any>> exceptionFunction)
Register a custom error function that gets invoked when the given
HttpStatus
predicate applies. |
private static final DefaultWebClient.DefaultResponseSpec.StatusHandler DEFAULT_STATUS_HANDLER
private final <any> responseMono
private java.util.List<DefaultWebClient.DefaultResponseSpec.StatusHandler> statusHandlers
public WebClient.ResponseSpec onStatus(java.util.function.Predicate<HttpStatus> statusPredicate, java.util.function.Function<ClientResponse,<any>> exceptionFunction)
WebClient.ResponseSpec
HttpStatus
predicate applies. The exception returned from the function will be returned from
WebClient.ResponseSpec.bodyToMono(Class)
and WebClient.ResponseSpec.bodyToFlux(Class)
.
By default, an error handler is register that throws a
WebClientResponseException
when the response status code is 4xx or 5xx.
onStatus
in interface WebClient.ResponseSpec
statusPredicate
- a predicate that indicates whether exceptionFunction
appliesexceptionFunction
- the function that returns the exceptionpublic <T> <any> bodyToMono(java.lang.Class<T> bodyType)
WebClient.ResponseSpec
Mono
. By default, if the response has status code 4xx or
5xx, the Mono
will contain a WebClientException
. This can be overridden
with WebClient.ResponseSpec.onStatus(Predicate, Function)
.bodyToMono
in interface WebClient.ResponseSpec
T
- response body typebodyType
- the expected response body typeWebClientResponseException
if the
status code is 4xx or 5xxpublic <T> <any> bodyToMono(ParameterizedTypeReference<T> typeReference)
WebClient.ResponseSpec
Mono
. By default, if the response has status code 4xx or
5xx, the Mono
will contain a WebClientException
. This can be overridden
with WebClient.ResponseSpec.onStatus(Predicate, Function)
.bodyToMono
in interface WebClient.ResponseSpec
T
- response body typetypeReference
- a type reference describing the expected response body typeWebClientResponseException
if the
status code is 4xx or 5xxprivate <T> <any> monoThrowableToMono(<any> mono)
public <T> <any> bodyToFlux(java.lang.Class<T> elementType)
WebClient.ResponseSpec
Flux
. By default, if the response has status code 4xx or
5xx, the Flux
will contain a WebClientException
. This can be overridden
with WebClient.ResponseSpec.onStatus(Predicate, Function)
.bodyToFlux
in interface WebClient.ResponseSpec
T
- the type of elements in the responseelementType
- the type of element in the responseWebClientResponseException
if the
status code is 4xx or 5xxpublic <T> <any> bodyToFlux(ParameterizedTypeReference<T> typeReference)
WebClient.ResponseSpec
Flux
. By default, if the response has status code 4xx or
5xx, the Flux
will contain a WebClientException
. This can be overridden
with WebClient.ResponseSpec.onStatus(Predicate, Function)
.bodyToFlux
in interface WebClient.ResponseSpec
T
- the type of elements in the responsetypeReference
- a type reference describing the expected response body typeWebClientResponseException
if the
status code is 4xx or 5xxprivate <T> <any> monoThrowableToFlux(<any> mono)
private <T extends <any>> T bodyToPublisher(ClientResponse response, BodyExtractor<T,? super ClientHttpResponse> extractor, java.util.function.Function<<any>,T> errorFunction)
private static <any> createResponseException(ClientResponse response)