Interface HandlerFilterFunction<T extends ServerResponse,R extends ServerResponse>
- Type Parameters:
T
- the type of the handler function to filterR
- the type of the response of the function
- 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 HandlerFilterFunction<T extends ServerResponse,R extends ServerResponse>
Represents a function that filters a handler function.
- Since:
- 5.2
- Author:
- Arjen Poutsma
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault HandlerFilterFunction<T,
R> andThen
(HandlerFilterFunction<T, T> after) Return a composed filter function that first applies this filter, and then applies theafter
filter.default HandlerFunction<R>
apply
(HandlerFunction<T> handler) Apply this filter to the given handler function, resulting in a filtered handler function.filter
(ServerRequest request, HandlerFunction<T> next) Apply this filter to the given handler function.static <T extends ServerResponse>
HandlerFilterFunction<T,T> ofErrorHandler
(Predicate<Throwable> predicate, BiFunction<Throwable, ServerRequest, T> errorHandler) Adapt the given predicate and response provider function to a filter function that returns aServerResponse
on a given exception.static <T extends ServerResponse>
HandlerFilterFunction<T,T> ofRequestProcessor
(Function<ServerRequest, ServerRequest> requestProcessor) Adapt the given request processor function to a filter function that only operates on theServerRequest
.static <T extends ServerResponse,
R extends ServerResponse>
HandlerFilterFunction<T,R> ofResponseProcessor
(BiFunction<ServerRequest, T, R> responseProcessor) Adapt the given response processor function to a filter function that only operates on theServerResponse
.
-
Method Details
-
filter
Apply this filter to the given handler function. The given handler function represents the next entity in the chain, and can be invoked in order to proceed to this entity, or not invoked to block the chain.- Parameters:
request
- the requestnext
- the next handler or filter function in the chain- Returns:
- the filtered response
- Throws:
Exception
-
andThen
Return a composed filter function that first applies this filter, and then applies theafter
filter.- Parameters:
after
- the filter to apply after this filter is applied- Returns:
- a composed filter that first applies this function and then applies the
after
function
-
apply
Apply this filter to the given handler function, resulting in a filtered handler function.- Parameters:
handler
- the handler function to filter- Returns:
- the filtered handler function
-
ofRequestProcessor
static <T extends ServerResponse> HandlerFilterFunction<T,T> ofRequestProcessor(Function<ServerRequest, ServerRequest> requestProcessor) Adapt the given request processor function to a filter function that only operates on theServerRequest
.- Parameters:
requestProcessor
- the request processor- Returns:
- the filter adaptation of the request processor
-
ofResponseProcessor
static <T extends ServerResponse,R extends ServerResponse> HandlerFilterFunction<T,R> ofResponseProcessor(BiFunction<ServerRequest, T, R> responseProcessor) Adapt the given response processor function to a filter function that only operates on theServerResponse
.- Parameters:
responseProcessor
- the response processor- Returns:
- the filter adaptation of the request processor
-
ofErrorHandler
static <T extends ServerResponse> HandlerFilterFunction<T,T> ofErrorHandler(Predicate<Throwable> predicate, BiFunction<Throwable, ServerRequest, T> errorHandler) Adapt the given predicate and response provider function to a filter function that returns aServerResponse
on a given exception.- Parameters:
predicate
- the predicate to match an exceptionerrorHandler
- the response provider- Returns:
- the filter adaption of the error handler
-