接口 RouterFunction<T extends ServerResponse>
- 类型参数:
T
- the type of the handler function to route to
- 函数接口:
- 这是一个函数接口, 因此可用作 lambda 表达式或方法引用的赋值目标。
@FunctionalInterface public interface RouterFunction<T extends ServerResponse>
Represents a function that routes to a handler function.- 从以下版本开始:
- 5.0
- 作者:
- Arjen Poutsma
- 另请参阅:
RouterFunctions
方法概要
所有方法 实例方法 抽象方法 默认方法 修饰符和类型 方法 说明 default void
accept(RouterFunctions.Visitor visitor)
Accept the given visitor.default RouterFunction<T>
and(RouterFunction<T> other)
Return a composed routing function that first invokes this function, and then invokes theother
function (of the same response typeT
) if this route had no result.default RouterFunction<T>
andNest(RequestPredicate predicate, RouterFunction<T> routerFunction)
Return a composed routing function that routes to the given router function if this route does not match and the given request predicate applies.default RouterFunction<?>
andOther(RouterFunction<?> other)
Return a composed routing function that first invokes this function, and then invokes theother
function (of a different response type) if this route had no result.default RouterFunction<T>
andRoute(RequestPredicate predicate, HandlerFunction<T> handlerFunction)
Return a composed routing function that routes to the given handler function if this route does not match and the given request predicate applies.default <S extends ServerResponse>
RouterFunction<S>filter(HandlerFilterFunction<T,S> filterFunction)
Filter all handler functions routed by this function with the given filter function.reactor.core.publisher.Mono<HandlerFunction<T>>
route(ServerRequest request)
Return the handler function that matches the given request.
方法详细资料
route
reactor.core.publisher.Mono<HandlerFunction<T>> route(ServerRequest request)
Return the handler function that matches the given request.- 参数:
request
- the request to route- 返回:
- an
Mono
describing theHandlerFunction
that matches this request, or an emptyMono
if there is no match
and
default RouterFunction<T> and(RouterFunction<T> other)
Return a composed routing function that first invokes this function, and then invokes theother
function (of the same response typeT
) if this route had no result.- 参数:
other
- the function of typeT
to apply when this function has no result- 返回:
- a composed function that first routes with this function and then the
other
function if this function has no result - 另请参阅:
andOther(RouterFunction)
andOther
default RouterFunction<?> andOther(RouterFunction<?> other)
Return a composed routing function that first invokes this function, and then invokes theother
function (of a different response type) if this route had no result.- 参数:
other
- the function to apply when this function has no result- 返回:
- a composed function that first routes with this function and then the
other
function if this function has no result - 另请参阅:
and(RouterFunction)
andRoute
default RouterFunction<T> andRoute(RequestPredicate predicate, HandlerFunction<T> handlerFunction)
Return a composed routing function that routes to the given handler function if this route does not match and the given request predicate applies. This method is a convenient combination ofand(RouterFunction)
andRouterFunctions.route(RequestPredicate, HandlerFunction)
.- 参数:
predicate
- the predicate to test if this route does not matchhandlerFunction
- the handler function to route to if this route does not match and the predicate applies- 返回:
- a composed function that route to
handlerFunction
if this route does not match and ifpredicate
applies
andNest
default RouterFunction<T> andNest(RequestPredicate predicate, RouterFunction<T> routerFunction)
Return a composed routing function that routes to the given router function if this route does not match and the given request predicate applies. This method is a convenient combination ofand(RouterFunction)
andRouterFunctions.nest(RequestPredicate, RouterFunction)
.- 参数:
predicate
- the predicate to test if this route does not matchrouterFunction
- the router function to route to if this route does not match and the predicate applies- 返回:
- a composed function that route to
routerFunction
if this route does not match and ifpredicate
applies
filter
default <S extends ServerResponse> RouterFunction<S> filter(HandlerFilterFunction<T,S> filterFunction)
Filter all handler functions routed by this function with the given filter function.- 类型参数:
S
- the filter return type- 参数:
filterFunction
- the filter to apply- 返回:
- the filtered routing function
accept
default void accept(RouterFunctions.Visitor visitor)
Accept the given visitor. Default implementation callsRouterFunctions.Visitor.unknown(RouterFunction)
; composedRouterFunction
implementations are expected to callaccept
for all components that make up this router function.- 参数:
visitor
- the visitor to accept