public abstract class RouterFunctions extends Object
RouterFunction given a
RequestPredicate and HandlerFunction, and to do further
subrouting on an existing routing
function.
Additionally, this class can transform a
RouterFunction into an HttpHandler, which can be run in Servlet 3.1+,
Reactor, RxNetty, or Undertow.
And it can transform a
RouterFunction into an HandlerMapping, which can be run in a
DispatcherHandler.
| Modifier and Type | Field and Description |
|---|---|
static String |
REQUEST_ATTRIBUTE
Name of the
ServerWebExchange attribute that contains the Request. |
static String |
URI_TEMPLATE_VARIABLES_ATTRIBUTE
Name of the
ServerWebExchange attribute that contains the URI
templates map, mapping variable names to values. |
| Constructor and Description |
|---|
RouterFunctions() |
| Modifier and Type | Method and Description |
|---|---|
static <T> RouterFunction<T> |
route(RequestPredicate predicate,
HandlerFunction<T> handlerFunction)
Route to the given handler function if the given request predicate applies.
|
static <T> RouterFunction<T> |
subroute(RequestPredicate predicate,
RouterFunction<T> routerFunction)
Route to the given routing function if the given request predicate applies.
|
static HandlerMapping |
toHandlerMapping(RouterFunction<?> routerFunction)
Convert the given
RouterFunction into a HandlerMapping. |
static HandlerMapping |
toHandlerMapping(RouterFunction<?> routerFunction,
StrategiesSupplier strategies)
Convert the given routing function into a
HandlerMapping,
using the given strategies. |
static org.springframework.http.server.reactive.HttpHandler |
toHttpHandler(RouterFunction<?> routerFunction)
Convert the given routing function into a
HttpHandler. |
static org.springframework.http.server.reactive.HttpHandler |
toHttpHandler(RouterFunction<?> routerFunction,
StrategiesSupplier strategies)
Convert the given routing function into a
HttpHandler,
using the given strategies. |
public static final String REQUEST_ATTRIBUTE
ServerWebExchange attribute that contains the Request.public static final String URI_TEMPLATE_VARIABLES_ATTRIBUTE
ServerWebExchange attribute that contains the URI
templates map, mapping variable names to values.public static <T> RouterFunction<T> route(RequestPredicate predicate, HandlerFunction<T> handlerFunction)
T - the type of the handler functionpredicate - the predicate to testhandlerFunction - the handler function to route tohandlerFunction if
predicate evaluates to trueRequestPredicatespublic static <T> RouterFunction<T> subroute(RequestPredicate predicate, RouterFunction<T> routerFunction)
T - the type of the handler functionpredicate - the predicate to testrouterFunction - the routing function to route torouterFunction if
predicate evaluates to trueRequestPredicatespublic static org.springframework.http.server.reactive.HttpHandler toHttpHandler(RouterFunction<?> routerFunction)
HttpHandler.
This conversion uses default strategies.
The returned HttpHandler can be adapted to run in
ServletHttpHandlerAdapter,ReactorHttpHandlerAdapter,RxNettyHttpHandlerAdapter, or UndertowHttpHandlerAdapter.routerFunction - the routing function to convertpublic static org.springframework.http.server.reactive.HttpHandler toHttpHandler(RouterFunction<?> routerFunction, StrategiesSupplier strategies)
HttpHandler,
using the given strategies.
The returned HttpHandler can be adapted to run in
ServletHttpHandlerAdapter,ReactorHttpHandlerAdapter,RxNettyHttpHandlerAdapter, or UndertowHttpHandlerAdapter.routerFunction - the routing function to convertstrategies - the strategies to usepublic static HandlerMapping toHandlerMapping(RouterFunction<?> routerFunction)
RouterFunction into a HandlerMapping.
This conversion uses default strategies.
The returned HandlerMapping can be run in a
DispatcherHandler.
routerFunction - the routing function to convertHandlerFunctionAdapter,
ResponseResultHandlerpublic static HandlerMapping toHandlerMapping(RouterFunction<?> routerFunction, StrategiesSupplier strategies)
HandlerMapping,
using the given strategies.
The returned HandlerMapping can be run in a
DispatcherHandler.
routerFunction - the routing function to convertstrategies - the strategies to useHandlerFunctionAdapter,
ResponseResultHandler