接口 RouterFunction<T extends ServerResponse>
- 类型参数:
T- the type of the handler function to route to
- 所有已知实现类:
RouterFunctionBuilder.BuiltRouterFunction,RouterFunctions.AbstractRouterFunction,RouterFunctions.AttributesRouterFunction,RouterFunctions.DefaultNestedRouterFunction,RouterFunctions.DefaultRouterFunction,RouterFunctions.DifferentComposedRouterFunction,RouterFunctions.FilteredRouterFunction,RouterFunctions.ResourcesRouterFunction,RouterFunctions.SameComposedRouterFunction
- 函数接口:
- 这是一个函数接口, 因此可用作 lambda 表达式或方法引用的赋值目标。
Represents a function that routes to a handler function.
- 从以下版本开始:
- 4.0
- 作者:
- Arjen Poutsma, Harry Yang
- 另请参阅:
-
方法概要
修饰符和类型方法说明default voidaccept(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 theotherfunction (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 theotherfunction (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.route(ServerRequest request) Return the handler function that matches the given request.default RouterFunction<T>withAttribute(String name, Object value) Return a new routing function with the given attribute.default RouterFunction<T>withAttributes(Consumer<Map<String, Object>> attributesConsumer) Return a new routing function with attributes manipulated with the given consumer.
-
方法详细资料
-
route
Return the handler function that matches the given request.- 参数:
request- the request to route- 返回:
- an
Optionaldescribing theHandlerFunctionthat matches this request, or an emptyOptionalif there is no match
-
and
Return a composed routing function that first invokes this function, and then invokes theotherfunction (of the same response typeT) if this route had no result.- 参数:
other- the function of typeTto apply when this function has no result- 返回:
- a composed function that first routes with this function and then the
otherfunction if this function has no result - 另请参阅:
-
andOther
Return a composed routing function that first invokes this function, and then invokes theotherfunction (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
otherfunction if this function has no result - 另请参阅:
-
andRoute
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
handlerFunctionif this route does not match and ifpredicateapplies
-
andNest
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
routerFunctionif this route does not match and ifpredicateapplies
-
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
Accept the given visitor. Default implementation callsRouterFunctions.Visitor.unknown(RouterFunction); composedRouterFunctionimplementations are expected to callacceptfor all components that make up this router function.- 参数:
visitor- the visitor to accept
-
withAttribute
Return a new routing function with the given attribute.- 参数:
name- the attribute namevalue- the attribute value- 返回:
- a function that has the specified attributes
-
withAttributes
Return a new routing function with attributes manipulated with the given consumer.The map provided to the consumer is "live", so that the consumer can be used to overwrite existing attributes, remove attributes, or use any of the other
Mapmethods.- 参数:
attributesConsumer- a function that consumes the attributes map- 返回:
- this builder
-