public static interface WebClient.ResponseSpec
Modifier and Type | Method and Description |
---|---|
<T> reactor.core.publisher.Flux<T> |
bodyToFlux(Class<T> elementType)
Extract the body to a
Flux . |
<T> reactor.core.publisher.Flux<T> |
bodyToFlux(ParameterizedTypeReference<T> typeReference)
Extract the body to a
Flux . |
<T> reactor.core.publisher.Mono<T> |
bodyToMono(Class<T> bodyType)
Extract the body to a
Mono . |
<T> reactor.core.publisher.Mono<T> |
bodyToMono(ParameterizedTypeReference<T> typeReference)
Extract the body to a
Mono . |
WebClient.ResponseSpec |
onStatus(Predicate<HttpStatus> statusPredicate,
Function<ClientResponse,reactor.core.publisher.Mono<? extends Throwable>> exceptionFunction)
Register a custom error function that gets invoked when the given
HttpStatus
predicate applies. |
WebClient.ResponseSpec onStatus(Predicate<HttpStatus> statusPredicate, Function<ClientResponse,reactor.core.publisher.Mono<? extends Throwable>> exceptionFunction)
HttpStatus
predicate applies. The exception returned from the function will be returned from
bodyToMono(Class)
and bodyToFlux(Class)
.
By default, an error handler is register that throws a
WebClientResponseException
when the response status code is 4xx or 5xx.
statusPredicate
- a predicate that indicates whether exceptionFunction
applies
NOTE: if the response is expected to have content, the exceptionFunction should consume it. If not, the content will be automatically drained to ensure resources are released.
exceptionFunction
- the function that returns the exception<T> reactor.core.publisher.Mono<T> bodyToMono(Class<T> bodyType)
Mono
. By default, if the response has status code 4xx or
5xx, the Mono
will contain a WebClientException
. This can be overridden
with onStatus(Predicate, Function)
.T
- response body typebodyType
- the expected response body typeWebClientResponseException
if the
status code is 4xx or 5xx<T> reactor.core.publisher.Mono<T> bodyToMono(ParameterizedTypeReference<T> typeReference)
Mono
. By default, if the response has status code 4xx or
5xx, the Mono
will contain a WebClientException
. This can be overridden
with onStatus(Predicate, Function)
.T
- response body typetypeReference
- a type reference describing the expected response body typeWebClientResponseException
if the
status code is 4xx or 5xx<T> reactor.core.publisher.Flux<T> bodyToFlux(Class<T> elementType)
Flux
. By default, if the response has status code 4xx or
5xx, the Flux
will contain a WebClientException
. This can be overridden
with onStatus(Predicate, Function)
.T
- the type of elements in the responseelementType
- the type of element in the responseWebClientResponseException
if the
status code is 4xx or 5xx<T> reactor.core.publisher.Flux<T> bodyToFlux(ParameterizedTypeReference<T> typeReference)
Flux
. By default, if the response has status code 4xx or
5xx, the Flux
will contain a WebClientException
. This can be overridden
with onStatus(Predicate, Function)
.T
- the type of elements in the responsetypeReference
- a type reference describing the expected response body typeWebClientResponseException
if the
status code is 4xx or 5xx