接口 ExchangeFunction
- 函数接口:
- 这是一个函数接口, 因此可用作 lambda 表达式或方法引用的赋值目标。
@FunctionalInterface public interface ExchangeFunction
Represents a function that exchanges a request for a (delayed) ClientResponse. Can be used as an alternative toWebClient
.For example:
ExchangeFunction exchangeFunction = ExchangeFunctions.create(new ReactorClientHttpConnector()); ClientRequest<Void> request = ClientRequest.method(HttpMethod.GET, "https://example.com/resource").build(); Mono<String> result = exchangeFunction .exchange(request) .then(response -> response.bodyToMono(String.class));
- 从以下版本开始:
- 5.0
- 作者:
- Arjen Poutsma
方法概要
所有方法 实例方法 抽象方法 默认方法 修饰符和类型 方法 说明 reactor.core.publisher.Mono<ClientResponse>
exchange(ClientRequest request)
Exchange the given request for a response mono.default ExchangeFunction
filter(ExchangeFilterFunction filter)
Filters this exchange function with the givenExchangeFilterFunction
, resulting in a filteredExchangeFunction
.
方法详细资料
exchange
reactor.core.publisher.Mono<ClientResponse> exchange(ClientRequest request)
Exchange the given request for a response mono.- 参数:
request
- the request to exchange- 返回:
- the delayed response
filter
default ExchangeFunction filter(ExchangeFilterFunction filter)
Filters this exchange function with the givenExchangeFilterFunction
, resulting in a filteredExchangeFunction
.- 参数:
filter
- the filter to apply to this exchange- 返回:
- the filtered exchange
- 另请参阅:
ExchangeFilterFunction.apply(ExchangeFunction)