public static interface WebClient.ResponseSpec
| Modifier and Type | Method and Description |
|---|---|
<T> reactor.core.publisher.Flux<T> |
bodyToFlux(Class<T> elementClass)
Extract the body to a
Flux. |
<T> reactor.core.publisher.Flux<T> |
bodyToFlux(ParameterizedTypeReference<T> elementTypeRef)
Extract the body to a
Flux. |
<T> reactor.core.publisher.Mono<T> |
bodyToMono(Class<T> elementClass)
Extract the body to a
Mono. |
<T> reactor.core.publisher.Mono<T> |
bodyToMono(ParameterizedTypeReference<T> elementTypeRef)
Extract the body to a
Mono. |
WebClient.ResponseSpec |
onRawStatus(IntPredicate statusCodePredicate,
Function<ClientResponse,reactor.core.publisher.Mono<? extends Throwable>> exceptionFunction)
Register a custom error function that gets invoked when the given raw status code
predicate applies.
|
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. |
reactor.core.publisher.Mono<ResponseEntity<Void>> |
toBodilessEntity()
Return the response as a delayed
ResponseEntity containing status and headers,
but no body. |
<T> reactor.core.publisher.Mono<ResponseEntity<T>> |
toEntity(Class<T> bodyClass)
Return the response as a delayed
ResponseEntity. |
<T> reactor.core.publisher.Mono<ResponseEntity<T>> |
toEntity(ParameterizedTypeReference<T> bodyTypeReference)
Return the response as a delayed
ResponseEntity. |
<T> reactor.core.publisher.Mono<ResponseEntity<List<T>>> |
toEntityList(Class<T> elementClass)
Return the response as a delayed list of
ResponseEntitys. |
<T> reactor.core.publisher.Mono<ResponseEntity<List<T>>> |
toEntityList(ParameterizedTypeReference<T> elementTypeRef)
Return the response as a delayed list of
ResponseEntitys. |
WebClient.ResponseSpec onStatus(Predicate<HttpStatus> statusPredicate, Function<ClientResponse,reactor.core.publisher.Mono<? extends Throwable>> exceptionFunction)
HttpStatus
predicate applies. Whatever exception is returned from the function (possibly using
ClientResponse.createException()) will also be returned as error signal
from bodyToMono(Class) and bodyToFlux(Class).
By default, an error handler is registered that returns a
WebClientResponseException when the response status code is 4xx or 5xx.
To override this default (and return a non-error response from bodyOn*), register
an exception function that returns an empty mono.
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.
statusPredicate - a predicate that indicates whether exceptionFunction
appliesexceptionFunction - the function that returns the exceptionClientResponse.createException()WebClient.ResponseSpec onRawStatus(IntPredicate statusCodePredicate, Function<ClientResponse,reactor.core.publisher.Mono<? extends Throwable>> exceptionFunction)
bodyToMono(Class) and bodyToFlux(Class).
By default, an error handler is registered that throws a
WebClientResponseException when the response status code is 4xx or 5xx.
statusCodePredicate - a predicate of the raw status code 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> elementClass)
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 typeelementClass - the expected response body element classWebClientResponseException if the
status code is 4xx or 5xx<T> reactor.core.publisher.Mono<T> bodyToMono(ParameterizedTypeReference<T> elementTypeRef)
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 typeelementTypeRef - a type reference describing the expected response body element typeWebClientResponseException if the
status code is 4xx or 5xx<T> reactor.core.publisher.Flux<T> bodyToFlux(Class<T> elementClass)
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 responseelementClass - the class of elements in the responseWebClientResponseException if the
status code is 4xx or 5xx<T> reactor.core.publisher.Flux<T> bodyToFlux(ParameterizedTypeReference<T> elementTypeRef)
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 responseelementTypeRef - a type reference describing the expected response body element typeWebClientResponseException if the
status code is 4xx or 5xx<T> reactor.core.publisher.Mono<ResponseEntity<T>> toEntity(Class<T> bodyClass)
ResponseEntity. 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 typebodyClass - the expected response body typeMono with the ResponseEntity<T> reactor.core.publisher.Mono<ResponseEntity<T>> toEntity(ParameterizedTypeReference<T> bodyTypeReference)
ResponseEntity. 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 typebodyTypeReference - a type reference describing the expected response body typeMono with the ResponseEntity<T> reactor.core.publisher.Mono<ResponseEntity<List<T>>> toEntityList(Class<T> elementClass)
ResponseEntitys. 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 - the type of elements in the listelementClass - the expected response body list element classMono with the list of ResponseEntitys<T> reactor.core.publisher.Mono<ResponseEntity<List<T>>> toEntityList(ParameterizedTypeReference<T> elementTypeRef)
ResponseEntitys. 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 - the type of elements in the listelementTypeRef - the expected response body list element reference typeMono with the list of ResponseEntitysreactor.core.publisher.Mono<ResponseEntity<Void>> toBodilessEntity()
ResponseEntity containing status and headers,
but no body. 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).
Calling this method will release the body of
the response.Mono with the bodiless ResponseEntity