类 DefaultWebClient.DefaultResponseSpec
java.lang.Object
cn.taketoday.web.reactive.function.client.DefaultWebClient.DefaultResponseSpec
- 所有已实现的接口:
WebClient.ResponseSpec
- 封闭类:
- DefaultWebClient
private static class DefaultWebClient.DefaultResponseSpec
extends Object
implements WebClient.ResponseSpec
-
嵌套类概要
嵌套类 -
字段概要
字段修饰符和类型字段说明private static final DefaultWebClient.DefaultResponseSpec.StatusHandlerprivate final intprivate final Supplier<HttpRequest>private final reactor.core.publisher.Mono<ClientResponse>private static final Predicate<HttpStatusCode>private final List<DefaultWebClient.DefaultResponseSpec.StatusHandler> -
构造器概要
构造器构造器说明DefaultResponseSpec(reactor.core.publisher.Mono<ClientResponse> responseMono, Supplier<HttpRequest> requestSupplier, List<DefaultWebClient.DefaultResponseSpec.StatusHandler> defaultStatusHandlers) -
方法概要
修饰符和类型方法说明private <T> reactor.core.publisher.Mono<T>applyStatusHandlers(ClientResponse response) <T> reactor.core.publisher.Flux<T>bodyToFlux(cn.taketoday.core.ParameterizedTypeReference<T> elementTypeRef) Variant ofWebClient.ResponseSpec.bodyToMono(Class)with aParameterizedTypeReference.<T> reactor.core.publisher.Flux<T>bodyToFlux(Class<T> elementClass) Decode the body to aFluxwith elements of the given type.<T> reactor.core.publisher.Mono<T>bodyToMono(cn.taketoday.core.ParameterizedTypeReference<T> elementTypeRef) Variant ofWebClient.ResponseSpec.bodyToMono(Class)with aParameterizedTypeReference.<T> reactor.core.publisher.Mono<T>bodyToMono(Class<T> elementClass) Decode the body to the given target type.exceptionWrappingFunction(ClientResponse response) private <T> org.reactivestreams.Publisher<T>handleBodyFlux(ClientResponse response, reactor.core.publisher.Flux<T> body) private <T> reactor.core.publisher.Mono<T>handleBodyMono(ClientResponse response, reactor.core.publisher.Mono<T> body) private <T> reactor.core.publisher.Mono<? extends ResponseEntity<reactor.core.publisher.Flux<T>>>handlerEntityFlux(ClientResponse response, reactor.core.publisher.Flux<T> body) private <T> reactor.core.publisher.Mono<T>insertCheckpoint(reactor.core.publisher.Mono<T> result, HttpStatusCode statusCode, HttpRequest request) onRawStatus(IntPredicate statusCodePredicate, Function<ClientResponse, reactor.core.publisher.Mono<? extends Throwable>> exceptionFunction) Variant ofWebClient.ResponseSpec.onStatus(Predicate, Function)that works with raw status code values.onStatus(Predicate<HttpStatusCode> statusCodePredicate, Function<ClientResponse, reactor.core.publisher.Mono<? extends Throwable>> exceptionFunction) Provide a function to map specific error status codes to an error signal to be propagated downstream instead of the response.reactor.core.publisher.Mono<ResponseEntity<Void>>Return aResponseEntitywithout a body.<T> reactor.core.publisher.Mono<ResponseEntity<T>>toEntity(cn.taketoday.core.ParameterizedTypeReference<T> bodyTypeRef) Variant ofWebClient.ResponseSpec.bodyToMono(Class)with aParameterizedTypeReference.<T> reactor.core.publisher.Mono<ResponseEntity<T>>Return aResponseEntitywith the body decoded to an Object of the given type.<T> reactor.core.publisher.Mono<ResponseEntity<reactor.core.publisher.Flux<T>>>toEntityFlux(cn.taketoday.core.ParameterizedTypeReference<T> elementTypeRef) Variant ofWebClient.ResponseSpec.toEntityFlux(Class)with aParameterizedTypeReference.<T> reactor.core.publisher.Mono<ResponseEntity<reactor.core.publisher.Flux<T>>>toEntityFlux(BodyExtractor<reactor.core.publisher.Flux<T>, ? super ClientHttpResponse> bodyExtractor) Variant ofWebClient.ResponseSpec.toEntityFlux(Class)with aBodyExtractor.<T> reactor.core.publisher.Mono<ResponseEntity<reactor.core.publisher.Flux<T>>>toEntityFlux(Class<T> elementType) Return aResponseEntitywith the body decoded to aFluxof elements of the given type.<T> reactor.core.publisher.Mono<ResponseEntity<List<T>>>toEntityList(cn.taketoday.core.ParameterizedTypeReference<T> elementTypeRef) Variant ofWebClient.ResponseSpec.toEntity(Class)with aParameterizedTypeReference.<T> reactor.core.publisher.Mono<ResponseEntity<List<T>>>toEntityList(Class<T> elementClass) Return aResponseEntitywith the body decoded to aListof elements of the given type.private static Predicate<HttpStatusCode>toStatusCodePredicate(IntPredicate predicate)
-
字段详细资料
-
STATUS_CODE_ERROR
-
DEFAULT_STATUS_HANDLER
-
responseMono
-
requestSupplier
-
statusHandlers
-
defaultStatusHandlerCount
private final int defaultStatusHandlerCount
-
-
构造器详细资料
-
DefaultResponseSpec
DefaultResponseSpec(reactor.core.publisher.Mono<ClientResponse> responseMono, Supplier<HttpRequest> requestSupplier, List<DefaultWebClient.DefaultResponseSpec.StatusHandler> defaultStatusHandlers)
-
-
方法详细资料
-
onStatus
public WebClient.ResponseSpec onStatus(Predicate<HttpStatusCode> statusCodePredicate, Function<ClientResponse, reactor.core.publisher.Mono<? extends Throwable>> exceptionFunction) 从接口复制的说明:WebClient.ResponseSpecProvide a function to map specific error status codes to an error signal to be propagated downstream instead of the response.By default, if there are no matching status handlers, responses with status codes >= 400 are mapped to
WebClientResponseExceptionwhich is created withClientResponse.createException().To suppress the treatment of a status code as an error and process it as a normal response, return
Mono.empty()from the function. The response will then propagate downstream to be processed.To ignore an error response completely, and propagate neither response nor error, use a
filter, or addonErrorResumedownstream, for example:webClient.get() .uri("https://abc.com/account/123") .retrieve() .bodyToMono(Account.class) .onErrorResume(WebClientResponseException.class, ex -> ex.getRawStatusCode() == 404 ? Mono.empty() : Mono.error(ex));- 指定者:
onStatus在接口中WebClient.ResponseSpec- 参数:
statusCodePredicate- to match responses withexceptionFunction- to map the response to an error signal- 返回:
- this builder
- 另请参阅:
-
onRawStatus
public WebClient.ResponseSpec onRawStatus(IntPredicate statusCodePredicate, Function<ClientResponse, reactor.core.publisher.Mono<? extends Throwable>> exceptionFunction) 从接口复制的说明:WebClient.ResponseSpecVariant ofWebClient.ResponseSpec.onStatus(Predicate, Function)that works with raw status code values. This is useful for custom status codes.- 指定者:
onRawStatus在接口中WebClient.ResponseSpec- 参数:
statusCodePredicate- to match responses withexceptionFunction- to map the response to an error signal- 返回:
- this builder
-
toStatusCodePredicate
-
bodyToMono
从接口复制的说明:WebClient.ResponseSpecDecode the body to the given target type. For an error response (status code of 4xx or 5xx), theMonoemits aWebClientException. UseWebClient.ResponseSpec.onStatus(Predicate, Function)to customize error response handling.- 指定者:
bodyToMono在接口中WebClient.ResponseSpec- 类型参数:
T- the target body type- 参数:
elementClass- the type to decode to- 返回:
- the decoded body
-
bodyToMono
public <T> reactor.core.publisher.Mono<T> bodyToMono(cn.taketoday.core.ParameterizedTypeReference<T> elementTypeRef) 从接口复制的说明:WebClient.ResponseSpecVariant ofWebClient.ResponseSpec.bodyToMono(Class)with aParameterizedTypeReference.- 指定者:
bodyToMono在接口中WebClient.ResponseSpec- 类型参数:
T- the target body type- 参数:
elementTypeRef- the type to decode to- 返回:
- the decoded body
-
bodyToFlux
从接口复制的说明:WebClient.ResponseSpecDecode the body to aFluxwith elements of the given type. For an error response (status code of 4xx or 5xx), theMonoemits aWebClientException. UseWebClient.ResponseSpec.onStatus(Predicate, Function)to customize error response handling.- 指定者:
bodyToFlux在接口中WebClient.ResponseSpec- 类型参数:
T- the body element type- 参数:
elementClass- the type of element to decode to- 返回:
- the decoded body
-
bodyToFlux
public <T> reactor.core.publisher.Flux<T> bodyToFlux(cn.taketoday.core.ParameterizedTypeReference<T> elementTypeRef) 从接口复制的说明:WebClient.ResponseSpecVariant ofWebClient.ResponseSpec.bodyToMono(Class)with aParameterizedTypeReference.- 指定者:
bodyToFlux在接口中WebClient.ResponseSpec- 类型参数:
T- the body element type- 参数:
elementTypeRef- the type of element to decode to- 返回:
- the decoded body
-
toEntity
从接口复制的说明:WebClient.ResponseSpecReturn aResponseEntitywith the body decoded to an Object of the given type. For an error response (status code of 4xx or 5xx), theMonoemits aWebClientException. UseWebClient.ResponseSpec.onStatus(Predicate, Function)to customize error response handling.- 指定者:
toEntity在接口中WebClient.ResponseSpec- 类型参数:
T- response body type- 参数:
bodyClass- the expected response body type- 返回:
- the
ResponseEntitywith the decoded body
-
toEntity
public <T> reactor.core.publisher.Mono<ResponseEntity<T>> toEntity(cn.taketoday.core.ParameterizedTypeReference<T> bodyTypeRef) 从接口复制的说明:WebClient.ResponseSpecVariant ofWebClient.ResponseSpec.bodyToMono(Class)with aParameterizedTypeReference.- 指定者:
toEntity在接口中WebClient.ResponseSpec- 类型参数:
T- the response body type- 参数:
bodyTypeRef- the expected response body type- 返回:
- the
ResponseEntitywith the decoded body
-
toEntityList
从接口复制的说明:WebClient.ResponseSpecReturn aResponseEntitywith the body decoded to aListof elements of the given type. For an error response (status code of 4xx or 5xx), theMonoemits aWebClientException. UseWebClient.ResponseSpec.onStatus(Predicate, Function)to customize error response handling.- 指定者:
toEntityList在接口中WebClient.ResponseSpec- 类型参数:
T- the body element type- 参数:
elementClass- the type of element to decode the target Flux to- 返回:
- the
ResponseEntity
-
toEntityList
public <T> reactor.core.publisher.Mono<ResponseEntity<List<T>>> toEntityList(cn.taketoday.core.ParameterizedTypeReference<T> elementTypeRef) 从接口复制的说明:WebClient.ResponseSpecVariant ofWebClient.ResponseSpec.toEntity(Class)with aParameterizedTypeReference.- 指定者:
toEntityList在接口中WebClient.ResponseSpec- 类型参数:
T- the body element type- 参数:
elementTypeRef- the type of element to decode the target Flux to- 返回:
- the
ResponseEntity
-
toEntityFlux
public <T> reactor.core.publisher.Mono<ResponseEntity<reactor.core.publisher.Flux<T>>> toEntityFlux(Class<T> elementType) 从接口复制的说明:WebClient.ResponseSpecReturn aResponseEntitywith the body decoded to aFluxof elements of the given type. For an error response (status code of 4xx or 5xx), theMonoemits aWebClientException. UseWebClient.ResponseSpec.onStatus(Predicate, Function)to customize error response handling.Note: The
Fluxrepresenting the body must be subscribed to or else associated resources will not be released.- 指定者:
toEntityFlux在接口中WebClient.ResponseSpec- 类型参数:
T- the body element type- 参数:
elementType- the type of element to decode the target Flux to- 返回:
- the
ResponseEntity
-
toEntityFlux
public <T> reactor.core.publisher.Mono<ResponseEntity<reactor.core.publisher.Flux<T>>> toEntityFlux(cn.taketoday.core.ParameterizedTypeReference<T> elementTypeRef) 从接口复制的说明:WebClient.ResponseSpecVariant ofWebClient.ResponseSpec.toEntityFlux(Class)with aParameterizedTypeReference.- 指定者:
toEntityFlux在接口中WebClient.ResponseSpec- 类型参数:
T- the body element type- 参数:
elementTypeRef- the type of element to decode the target Flux to- 返回:
- the
ResponseEntity
-
toEntityFlux
public <T> reactor.core.publisher.Mono<ResponseEntity<reactor.core.publisher.Flux<T>>> toEntityFlux(BodyExtractor<reactor.core.publisher.Flux<T>, ? super ClientHttpResponse> bodyExtractor) 从接口复制的说明:WebClient.ResponseSpecVariant ofWebClient.ResponseSpec.toEntityFlux(Class)with aBodyExtractor.- 指定者:
toEntityFlux在接口中WebClient.ResponseSpec- 类型参数:
T- the body element type- 参数:
bodyExtractor- theBodyExtractorthat reads from the response- 返回:
- the
ResponseEntity
-
toBodilessEntity
从接口复制的说明:WebClient.ResponseSpecReturn aResponseEntitywithout a body. For an error response (status code of 4xx or 5xx), theMonoemits aWebClientException. UseWebClient.ResponseSpec.onStatus(Predicate, Function)to customize error response handling.- 指定者:
toBodilessEntity在接口中WebClient.ResponseSpec- 返回:
- the
ResponseEntity
-
handleBodyMono
private <T> reactor.core.publisher.Mono<T> handleBodyMono(ClientResponse response, reactor.core.publisher.Mono<T> body) -
handleBodyFlux
private <T> org.reactivestreams.Publisher<T> handleBodyFlux(ClientResponse response, reactor.core.publisher.Flux<T> body) -
handlerEntityFlux
private <T> reactor.core.publisher.Mono<? extends ResponseEntity<reactor.core.publisher.Flux<T>>> handlerEntityFlux(ClientResponse response, reactor.core.publisher.Flux<T> body) -
exceptionWrappingFunction
private <T> Function<Throwable,reactor.core.publisher.Mono<? extends T>> exceptionWrappingFunction(ClientResponse response) -
applyStatusHandlers
-
insertCheckpoint
private <T> reactor.core.publisher.Mono<T> insertCheckpoint(reactor.core.publisher.Mono<T> result, HttpStatusCode statusCode, HttpRequest request)
-