接口 HandlerFilterFunction<T extends ServerResponse,R extends ServerResponse>
- 类型参数:
T
- the type of the handler function to filterR
- the type of the response of the function
- 函数接口:
- 这是一个函数接口, 因此可用作 lambda 表达式或方法引用的赋值目标。
@FunctionalInterface public interface HandlerFilterFunction<T extends ServerResponse,R extends ServerResponse>
Represents a function that filters a handler function.- 从以下版本开始:
- 5.2
- 作者:
- Arjen Poutsma
- 另请参阅:
RouterFunction.filter(HandlerFilterFunction)
方法概要
所有方法 静态方法 实例方法 抽象方法 默认方法 修饰符和类型 方法 说明 default 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.R
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
.
方法详细资料
filter
R filter(ServerRequest request, HandlerFunction<T> next) throws Exception
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.- 参数:
request
- the requestnext
- the next handler or filter function in the chain- 返回:
- the filtered response
- 抛出:
Exception
andThen
default HandlerFilterFunction<T,R> andThen(HandlerFilterFunction<T,T> after)
Return a composed filter function that first applies this filter, and then applies theafter
filter.- 参数:
after
- the filter to apply after this filter is applied- 返回:
- a composed filter that first applies this function and then applies the
after
function
apply
default HandlerFunction<R> apply(HandlerFunction<T> handler)
Apply this filter to the given handler function, resulting in a filtered handler function.- 参数:
handler
- the handler function to filter- 返回:
- 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
.- 参数:
requestProcessor
- the request processor- 返回:
- 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
.- 参数:
responseProcessor
- the response processor- 返回:
- 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.- 参数:
predicate
- the predicate to match an exceptionerrorHandler
- the response provider- 返回:
- the filter adaption of the error handler