Add WebClient.filter method
This commit introduces a new method on WebClient: filter, which takes an filter function, and returns a (filtered) WebClient. Issue: SPR-14961
This commit is contained in:
@@ -95,6 +95,14 @@ class DefaultWebClientBuilder implements WebClient.Builder {
|
||||
this.strategies));
|
||||
}
|
||||
|
||||
@Override
|
||||
public WebClient filter(ExchangeFilterFunction filter) {
|
||||
Assert.notNull(filter, "'filter' must not be null");
|
||||
|
||||
ExchangeFilterFunction composedFilter = filter.andThen(this.filter);
|
||||
|
||||
return new DefaultWebClient(this.clientHttpConnector, this.strategies, composedFilter);
|
||||
}
|
||||
}
|
||||
|
||||
private class NoOpFilter implements ExchangeFilterFunction {
|
||||
|
||||
@@ -50,6 +50,15 @@ public interface WebClient extends ExchangeFunction {
|
||||
@Override
|
||||
Mono<ClientResponse> exchange(ClientRequest<?> request);
|
||||
|
||||
/**
|
||||
* Filters this client with the given {@code ExchangeFilterFunction}, resulting in a filtered
|
||||
* {@code WebClient}.
|
||||
* @param filterFunction the filter to apply to this client
|
||||
* @return the filtered client
|
||||
* @see ExchangeFilterFunction#apply(ExchangeFunction)
|
||||
*/
|
||||
WebClient filter(ExchangeFilterFunction filterFunction);
|
||||
|
||||
|
||||
/**
|
||||
* Create a new instance of {@code WebClient} with the given connector. This method uses
|
||||
|
||||
Reference in New Issue
Block a user