@FunctionalInterface public interface ExchangeFunction
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));
Modifier and Type | Method and Description |
---|---|
reactor.core.publisher.Mono<ClientResponse> |
exchange(ClientRequest request)
Exchange the given request for a
ClientResponse promise. |
default ExchangeFunction |
filter(ExchangeFilterFunction filter)
Filter the exchange function with the given
ExchangeFilterFunction ,
resulting in a filtered ExchangeFunction . |
reactor.core.publisher.Mono<ClientResponse> exchange(ClientRequest request)
ClientResponse
promise.
Note: When calling this method from an
ExchangeFilterFunction
that 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 the
WebClient
. Please, see the reference documentation for more
details on this.
request
- the request to exchangedefault ExchangeFunction filter(ExchangeFilterFunction filter)
ExchangeFilterFunction
,
resulting in a filtered ExchangeFunction
.filter
- the filter to apply to this exchangeExchangeFilterFunction.apply(ExchangeFunction)