Interface ExchangeFunction
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@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));
- Since:
- 5.0
- Author:
- Arjen Poutsma
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description 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
.
Method Detail
exchange
reactor.core.publisher.Mono<ClientResponse> exchange(ClientRequest request)
Exchange the given request for a response mono.- Parameters:
request
- the request to exchange- Returns:
- the delayed response
filter
default ExchangeFunction filter(ExchangeFilterFunction filter)
Filters this exchange function with the givenExchangeFilterFunction
, resulting in a filteredExchangeFunction
.- Parameters:
filter
- the filter to apply to this exchange- Returns:
- the filtered exchange
- See Also:
ExchangeFilterFunction.apply(ExchangeFunction)