Interface RouterFunction<T extends ServerResponse>
- Type Parameters:
- T- the type of the handler function to route to
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Represents a function that routes to a handler function.
- Since:
- 5.0
- Author:
- Arjen Poutsma
- See Also:
- 
Method SummaryModifier and TypeMethodDescriptiondefault 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.reactor.core.publisher.Mono<HandlerFunction<T>> 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.
- 
Method Details- 
routeReturn the handler function that matches the given request.- Parameters:
- request- the request to route
- Returns:
- an Monodescribing theHandlerFunctionthat matches this request, or an emptyMonoif there is no match
 
- 
andReturn a composed routing function that first invokes this function, and then invokes theotherfunction (of the same response typeT) if this route had no result.- Parameters:
- other- the function of type- Tto apply when this function has no result
- Returns:
- a composed function that first routes with this function and then the
otherfunction if this function has no result
- See Also:
 
- 
andOtherReturn a composed routing function that first invokes this function, and then invokes theotherfunction (of a different response type) if this route had no result.- Parameters:
- other- the function to apply when this function has no result
- Returns:
- a composed function that first routes with this function and then the
otherfunction if this function has no result
- See Also:
 
- 
andRouteReturn 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).- Parameters:
- predicate- the predicate to test if this route does not match
- handlerFunction- the handler function to route to if this route does not match and the predicate applies
- Returns:
- a composed function that route to handlerFunctionif this route does not match and ifpredicateapplies
 
- 
andNestReturn 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).- Parameters:
- predicate- the predicate to test if this route does not match
- routerFunction- the router function to route to if this route does not match and the predicate applies
- Returns:
- a composed function that route to routerFunctionif this route does not match and ifpredicateapplies
 
- 
filterdefault <S extends ServerResponse> RouterFunction<S> filter(HandlerFilterFunction<T, S> filterFunction) Filter all handler functions routed by this function with the given filter function.- Type Parameters:
- S- the filter return type
- Parameters:
- filterFunction- the filter to apply
- Returns:
- the filtered routing function
 
- 
acceptAccept the given visitor. Default implementation callsRouterFunctions.Visitor.unknown(RouterFunction); composedRouterFunctionimplementations are expected to callacceptfor all components that make up this router function.- Parameters:
- visitor- the visitor to accept
 
- 
withAttributeReturn a new routing function with the given attribute.- Parameters:
- name- the attribute name
- value- the attribute value
- Returns:
- a function that has the specified attributes
- Since:
- 5.3
 
- 
withAttributesReturn 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.- Parameters:
- attributesConsumer- a function that consumes the attributes map
- Returns:
- this builder
- Since:
- 5.3
 
 
-