Interface ExchangeFilterFunction
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Represents a function that filters an exchange function.
The filter is executed when a Subscriber
subscribes to the
Publisher
returned by the WebClient
.
- Since:
- 5.0
- Author:
- Arjen Poutsma
-
Method Summary
Modifier and TypeMethodDescriptiondefault ExchangeFilterFunction
andThen
(ExchangeFilterFunction afterFilter) Return a composed filter function that first applies this filter, and then applies the given"after"
filter.default ExchangeFunction
apply
(ExchangeFunction exchange) Apply this filter to the given ExchangeFunction, resulting in a filtered exchange function.reactor.core.publisher.Mono<ClientResponse>
filter
(ClientRequest request, ExchangeFunction next) Apply this filter to the given request and exchange function.static ExchangeFilterFunction
ofRequestProcessor
(Function<ClientRequest, reactor.core.publisher.Mono<ClientRequest>> processor) Adapt the given request processor function to a filter function that only operates on theClientRequest
.static ExchangeFilterFunction
ofResponseProcessor
(Function<ClientResponse, reactor.core.publisher.Mono<ClientResponse>> processor) Adapt the given response processor function to a filter function that only operates on theClientResponse
.
-
Method Details
-
filter
Apply this filter to the given request and exchange function.The given ExchangeFunction represents the next entity in the chain, to be invoked via invoked in order to proceed with the exchange, or not invoked to shortcut the chain.
Note: When a filter handles the response after the call to
ExchangeFunction.exchange(org.springframework.web.reactive.function.client.ClientRequest)
, 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.- Parameters:
request
- the current requestnext
- the next exchange function in the chain- Returns:
- the filtered response
-
andThen
Return a composed filter function that first applies this filter, and then applies the given"after"
filter.- Parameters:
afterFilter
- the filter to apply after this filter- Returns:
- the composed filter
-
apply
Apply this filter to the given ExchangeFunction, resulting in a filtered exchange function.- Parameters:
exchange
- the exchange function to filter- Returns:
- the filtered exchange function
-
ofRequestProcessor
static ExchangeFilterFunction ofRequestProcessor(Function<ClientRequest, reactor.core.publisher.Mono<ClientRequest>> processor) Adapt the given request processor function to a filter function that only operates on theClientRequest
.- Parameters:
processor
- the request processor- Returns:
- the resulting filter adapter
-
ofResponseProcessor
static ExchangeFilterFunction ofResponseProcessor(Function<ClientResponse, reactor.core.publisher.Mono<ClientResponse>> processor) Adapt the given response processor function to a filter function that only operates on theClientResponse
.- Parameters:
processor
- the response processor- Returns:
- the resulting filter adapter
-