接口 ExchangeFunction
- 函数接口:
- 这是一个函数接口, 因此可用作 lambda 表达式或方法引用的赋值目标。
Represents a function that exchanges a request for a (delayed)
ClientResponse. Can be used as an alternative to
WebClient.
For example:
ExchangeFunction exchangeFunction =
ExchangeFunctions.create(new ReactorClientHttpConnector());
URI url = URI.create("https://example.com/resource");
ClientRequest request = ClientRequest.create(HttpMethod.GET, url).build();
Mono<String> bodyMono = exchangeFunction
.exchange(request)
.flatMap(response -> response.bodyToMono(String.class));
- 从以下版本开始:
- 4.0
- 作者:
- Arjen Poutsma
-
方法概要
修饰符和类型方法说明reactor.core.publisher.Mono<ClientResponse>exchange(ClientRequest request) Exchange the given request for aClientResponsepromise.default ExchangeFunctionfilter(ExchangeFilterFunction filter) Filter the exchange function with the givenExchangeFilterFunction, resulting in a filteredExchangeFunction.
-
方法详细资料
-
exchange
Exchange the given request for aClientResponsepromise.Note: When calling this method from an
ExchangeFilterFunctionthat handles the response in some way, extra care must be taken to always consume its content or otherwise propagate it downstream for further handling, for example by theWebClient. Please, see the reference documentation for more details on this.- 参数:
request- the request to exchange- 返回:
- the delayed response
-
filter
Filter the exchange function with the givenExchangeFilterFunction, resulting in a filteredExchangeFunction.- 参数:
filter- the filter to apply to this exchange- 返回:
- the filtered exchange
- 另请参阅:
-