@Singleton public class DefaultRouter extends Object implements Router
The default Router
implementation. This implementation does not perform any additional caching of
route discovery.
Constructor and Description |
---|
DefaultRouter(Collection<RouteBuilder> builders)
Construct a new router for the given route builders.
|
DefaultRouter(RouteBuilder... builders)
Construct a new router for the given route builders.
|
Modifier and Type | Method and Description |
---|---|
<T,R> Stream<UriRouteMatch<T,R>> |
find(HttpMethod httpMethod,
CharSequence uri)
Finds all of the possible routes for the given HTTP method and URI.
|
<T,R> Stream<UriRouteMatch<T,R>> |
findAny(CharSequence uri)
Find any
RouteMatch regardless of HTTP method. |
List<HttpFilter> |
findFilters(HttpRequest<?> request)
Build a filtered
Publisher for an action. |
<R> Optional<RouteMatch<R>> |
route(Class originatingClass,
HttpStatus status)
Found a
RouteMatch for the given HttpStatus code. |
<R> Optional<RouteMatch<R>> |
route(Class originatingClass,
Throwable error)
Match a route to an error.
|
<T,R> Optional<UriRouteMatch<T,R>> |
route(HttpMethod httpMethod,
CharSequence uri)
Finds the first possible route for the given HTTP method and URI.
|
<R> Optional<RouteMatch<R>> |
route(HttpStatus status)
Found a
RouteMatch for the given HttpStatus code. |
<R> Optional<RouteMatch<R>> |
route(Throwable error)
Match a route to an error.
|
Stream<UriRoute> |
uriRoutes()
Returns all UriRoutes.
|
@Inject public DefaultRouter(Collection<RouteBuilder> builders)
builders
- The builderspublic DefaultRouter(RouteBuilder... builders)
builders
- The builderspublic <T,R> Stream<UriRouteMatch<T,R>> find(HttpMethod httpMethod, CharSequence uri)
Router
public Stream<UriRoute> uriRoutes()
Router
public <T,R> Optional<UriRouteMatch<T,R>> route(HttpMethod httpMethod, CharSequence uri)
Router
public <R> Optional<RouteMatch<R>> route(HttpStatus status)
Router
RouteMatch
for the given HttpStatus
code.route
in interface Router
R
- The matched routestatus
- The HTTP statusRouteMatch
public <R> Optional<RouteMatch<R>> route(Class originatingClass, HttpStatus status)
Router
RouteMatch
for the given HttpStatus
code.route
in interface Router
R
- The matched routeoriginatingClass
- The class the error originates fromstatus
- The HTTP statusRouteMatch
public <R> Optional<RouteMatch<R>> route(Class originatingClass, Throwable error)
Router
route
in interface Router
R
- The matched routeoriginatingClass
- The class the error originates fromerror
- The errorRouteMatch
public <R> Optional<RouteMatch<R>> route(Throwable error)
Router
route
in interface Router
R
- The matched routeerror
- The errorRouteMatch
public List<HttpFilter> findFilters(HttpRequest<?> request)
Router
Publisher
for an action.findFilters
in interface Router
request
- The requestpublic <T,R> Stream<UriRouteMatch<T,R>> findAny(CharSequence uri)
Router
RouteMatch
regardless of HTTP method.