Class ExchangeFilterFunctions
java.lang.Object
org.springframework.web.reactive.function.client.ExchangeFilterFunctions
Static factory methods providing access to built-in implementations of
ExchangeFilterFunction for basic authentication, error handling, etc.- Since:
- 5.0
- Author:
- Rob Winch, Arjen Poutsma, Sam Brannen
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ExchangeFilterFunctionbasicAuthentication(String username, String password) Return a filter that applies HTTP Basic Authentication to the request headers viaHttpHeaders.setBasicAuth(String)andHttpHeaders.encodeBasicAuth(String, String, Charset).static ExchangeFilterFunctionlimitResponseSize(long maxByteCount) Consume up to the specified number of bytes from the response body and cancel if any more data arrives.static ExchangeFilterFunctionstatusError(Predicate<org.springframework.http.HttpStatusCode> statusPredicate, Function<ClientResponse, ? extends Throwable> exceptionFunction) Return a filter that generates an error signal when the givenHttpStatusCodepredicate matches.
-
Constructor Details
-
ExchangeFilterFunctions
public ExchangeFilterFunctions()
-
-
Method Details
-
limitResponseSize
Consume up to the specified number of bytes from the response body and cancel if any more data arrives.Internally delegates to
DataBufferUtils.takeUntilByteCount(Publisher, long).- Parameters:
maxByteCount- the limit as number of bytes- Returns:
- the filter to limit the response size with
- Since:
- 5.1
-
statusError
public static ExchangeFilterFunction statusError(Predicate<org.springframework.http.HttpStatusCode> statusPredicate, Function<ClientResponse, ? extends Throwable> exceptionFunction) Return a filter that generates an error signal when the givenHttpStatusCodepredicate matches.- Parameters:
statusPredicate- the predicate to check the HTTP status withexceptionFunction- the function to create the exception- Returns:
- the filter to generate an error signal
-
basicAuthentication
Return a filter that applies HTTP Basic Authentication to the request headers viaHttpHeaders.setBasicAuth(String)andHttpHeaders.encodeBasicAuth(String, String, Charset).- Parameters:
username- the usernamepassword- the password- Returns:
- the filter to add authentication headers with
- See Also:
-