インターフェース WebClient.ResponseSpec
- 含まれているインターフェース:
- WebClient
public static interface WebClient.ResponseSpec
交換後のレスポンス操作を指定するための契約。
メソッドのサマリー
修飾子と型メソッド説明<T> reactor.core.publisher.Flux<T>bodyToFlux(ClassSE<T> elementClass) 指定された型の要素を使用して、本体をFluxにデコードします。<T> reactor.core.publisher.Flux<T>bodyToFlux(ParameterizedTypeReference<T> elementTypeRef) ParameterizedTypeReferenceを使用したbodyToMono(Class)のバリアント。<T> reactor.core.publisher.Mono<T>bodyToMono(ClassSE<T> elementClass) 本体を指定されたターゲット型にデコードします。<T> reactor.core.publisher.Mono<T>bodyToMono(ParameterizedTypeReference<T> elementTypeRef) ParameterizedTypeReferenceを使用したbodyToMono(Class)のバリアント。onRawStatus(IntPredicateSE statusCodePredicate, FunctionSE<ClientResponse, reactor.core.publisher.Mono<? extends ThrowableSE>> exceptionFunction) 生のステータスコード値を処理するonStatus(Predicate, Function)のバリアント。onStatus(PredicateSE<HttpStatusCode> statusPredicate, FunctionSE<ClientResponse, reactor.core.publisher.Mono<? extends ThrowableSE>> exceptionFunction) 特定のエラーステータスコードをエラーシグナルにマップして、レスポンスではなく下流に伝搬する関数を提供します。reactor.core.publisher.Mono<ResponseEntity<VoidSE>>本体なしでResponseEntityを返します。<T> reactor.core.publisher.Mono<ResponseEntity<T>>指定された型のオブジェクトにデコードされた本体を持つResponseEntityを返します。<T> reactor.core.publisher.Mono<ResponseEntity<T>>toEntity(ParameterizedTypeReference<T> bodyTypeReference) ParameterizedTypeReferenceを使用したbodyToMono(Class)のバリアント。<T> reactor.core.publisher.Mono<ResponseEntity<reactor.core.publisher.Flux<T>>>toEntityFlux(ClassSE<T> elementType) 指定された型の要素のFluxに本体がデコードされたResponseEntityを返します。<T> reactor.core.publisher.Mono<ResponseEntity<reactor.core.publisher.Flux<T>>>toEntityFlux(ParameterizedTypeReference<T> elementTypeReference) ParameterizedTypeReferenceを使用したtoEntityFlux(Class)のバリアント。<T> reactor.core.publisher.Mono<ResponseEntity<reactor.core.publisher.Flux<T>>>toEntityFlux(BodyExtractor<reactor.core.publisher.Flux<T>, ? super ClientHttpResponse> bodyExtractor) BodyExtractorを使用したtoEntityFlux(Class)のバリアント。<T> reactor.core.publisher.Mono<ResponseEntity<ListSE<T>>>toEntityList(ClassSE<T> elementClass) 指定された型の要素のListに本体がデコードされたResponseEntityを返します。<T> reactor.core.publisher.Mono<ResponseEntity<ListSE<T>>>toEntityList(ParameterizedTypeReference<T> elementTypeRef) ParameterizedTypeReferenceを使用したtoEntity(Class)のバリアント。
メソッドの詳細
onStatus
WebClient.ResponseSpec onStatus(PredicateSE<HttpStatusCode> statusPredicate, FunctionSE<ClientResponse, reactor.core.publisher.Mono<? extends ThrowableSE>> exceptionFunction) 特定のエラーステータスコードをエラーシグナルにマップして、レスポンスではなく下流に伝搬する関数を提供します。デフォルトでは、一致するステータスハンドラーがない場合、ステータスコードが 400 以上のレスポンスは、
ClientResponse.createException()で作成されたWebClientResponseExceptionにマップされます。エラーとしてのステータスコードの処理を抑制し、それを通常のレスポンスとして処理するには、関数から
Mono.empty()を返します。その後、レスポンスはダウンストリームに伝搬されて処理されます。エラーレスポンスを完全に無視し、レスポンスもエラーも伝播しないようにするには、
filterを使用するか、onErrorResumeダウンストリームを追加します。例:webClient.get() .uri("https://abc.com/account/123") .retrieve() .bodyToMono(Account.class) .onErrorResume(WebClientResponseException.class, ex -> ex.getStatusCode().value() == 404 ? Mono.empty() : Mono.error(ex));- パラメーター:
statusPredicate- レスポンスを一致させるexceptionFunction- レスポンスをエラーシグナルにマッピングする- 戻り値:
- このビルダー
- 関連事項:
onRawStatus
WebClient.ResponseSpec onRawStatus(IntPredicateSE statusCodePredicate, FunctionSE<ClientResponse, reactor.core.publisher.Mono<? extends ThrowableSE>> exceptionFunction) 生のステータスコード値を処理するonStatus(Predicate, Function)のバリアント。これは、カスタムステータスコードに役立ちます。- パラメーター:
statusCodePredicate- レスポンスを一致させるexceptionFunction- レスポンスをエラーシグナルにマッピングする- 戻り値:
- このビルダー
- 導入:
- 5.1.9
bodyToMono
本体を指定されたターゲット型にデコードします。エラーレスポンス(ステータスコード 4xx または 5xx)の場合、MonoはWebClientExceptionを発行します。onStatus(Predicate, Function)を使用して、エラーレスポンス処理をカスタマイズします。- 型パラメーター:
T- 対象の体型- パラメーター:
elementClass- デコードする型- 戻り値:
- デコードされた本体
bodyToMono
ParameterizedTypeReferenceを使用したbodyToMono(Class)のバリアント。- 型パラメーター:
T- 対象の体型- パラメーター:
elementTypeRef- デコードする型- 戻り値:
- デコードされた本体
bodyToFlux
指定された型の要素を使用して、本体をFluxにデコードします。エラーレスポンス(ステータスコード 4xx または 5xx)の場合、MonoはWebClientExceptionを発行します。onStatus(Predicate, Function)を使用して、エラーレスポンス処理をカスタマイズします。- 型パラメーター:
T- ボディ要素型- パラメーター:
elementClass- デコードする要素の型- 戻り値:
- デコードされた本体
bodyToFlux
ParameterizedTypeReferenceを使用したbodyToMono(Class)のバリアント。- 型パラメーター:
T- ボディ要素型- パラメーター:
elementTypeRef- デコードする要素の型- 戻り値:
- デコードされた本体
toEntity
指定された型のオブジェクトにデコードされた本体を持つResponseEntityを返します。エラーレスポンス(ステータスコード 4xx または 5xx)の場合、MonoはWebClientExceptionを発行します。onStatus(Predicate, Function)を使用して、エラーレスポンス処理をカスタマイズします。- 型パラメーター:
T- レスポンス本体型- パラメーター:
bodyClass- 予想されるレスポンス本文型- 戻り値:
- デコードされたボディを持つ
ResponseEntity - 導入:
- 5.2
toEntity
<T> reactor.core.publisher.Mono<ResponseEntity<T>> toEntity(ParameterizedTypeReference<T> bodyTypeReference) ParameterizedTypeReferenceを使用したbodyToMono(Class)のバリアント。- 型パラメーター:
T- レスポンス本体型- パラメーター:
bodyTypeReference- 予想されるレスポンス本文型- 戻り値:
- デコードされたボディを持つ
ResponseEntity - 導入:
- 5.2
toEntityList
指定された型の要素のListに本体がデコードされたResponseEntityを返します。エラーレスポンス(ステータスコード 4xx または 5xx)の場合、MonoはWebClientExceptionを発行します。onStatus(Predicate, Function)を使用して、エラーレスポンス処理をカスタマイズします。- 型パラメーター:
T- ボディ要素型- パラメーター:
elementClass- ターゲット Flux をデコードする要素の型- 戻り値:
ResponseEntity- 導入:
- 5.2
toEntityList
<T> reactor.core.publisher.Mono<ResponseEntity<ListSE<T>>> toEntityList(ParameterizedTypeReference<T> elementTypeRef) ParameterizedTypeReferenceを使用したtoEntity(Class)のバリアント。- 型パラメーター:
T- ボディ要素型- パラメーター:
elementTypeRef- ターゲット Flux をデコードする要素の型- 戻り値:
ResponseEntity- 導入:
- 5.2
toEntityFlux
<T> reactor.core.publisher.Mono<ResponseEntity<reactor.core.publisher.Flux<T>>> toEntityFlux(ClassSE<T> elementType) 指定された型の要素のFluxに本体がデコードされたResponseEntityを返します。エラーレスポンス(ステータスコード 4xx または 5xx)の場合、MonoはWebClientExceptionを発行します。onStatus(Predicate, Function)を使用して、エラーレスポンス処理をカスタマイズします。注意 : 本体を表す
Fluxはサブスクライブする必要があります。サブスクライブしないと、関連するリソースが解放されません。- 型パラメーター:
T- ボディ要素型- パラメーター:
elementType- ターゲット Flux をデコードする要素の型- 戻り値:
ResponseEntity- 導入:
- 5.3.1
toEntityFlux
<T> reactor.core.publisher.Mono<ResponseEntity<reactor.core.publisher.Flux<T>>> toEntityFlux(ParameterizedTypeReference<T> elementTypeReference) ParameterizedTypeReferenceを使用したtoEntityFlux(Class)のバリアント。- 型パラメーター:
T- ボディ要素型- パラメーター:
elementTypeReference- ターゲット Flux をデコードする要素の型- 戻り値:
ResponseEntity- 導入:
- 5.3.1
toEntityFlux
<T> reactor.core.publisher.Mono<ResponseEntity<reactor.core.publisher.Flux<T>>> toEntityFlux(BodyExtractor<reactor.core.publisher.Flux<T>, ? super ClientHttpResponse> bodyExtractor) BodyExtractorを使用したtoEntityFlux(Class)のバリアント。- 型パラメーター:
T- ボディ要素型- パラメーター:
bodyExtractor- レスポンスから読み取るBodyExtractor- 戻り値:
ResponseEntity- 導入:
- 5.3.2
toBodilessEntity
reactor.core.publisher.Mono<ResponseEntity<VoidSE>> toBodilessEntity()本体なしでResponseEntityを返します。エラーレスポンス(ステータスコード 4xx または 5xx)の場合、MonoはWebClientExceptionを発行します。onStatus(Predicate, Function)を使用して、エラーレスポンス処理をカスタマイズします。- 戻り値:
ResponseEntity- 導入:
- 5.2