public class FilteredRouter extends Object implements Router
Router
with filtering capabilities.
Filters themselves should be supplied via the RouteMatchFilter
interface.
A filtered router can be enabled by implementing a BeanCreatedEventListener
for
the existing Router
and decorating appropriately. See for example VersionAwareRouterListener
RouteMatchFilter
Constructor and Description |
---|
FilteredRouter(Router router,
RouteMatchFilter routeFilter)
Creates a decorated router for an existing router and
RouteMatchFilter . |
Modifier and Type | Method and Description |
---|---|
<T,R> Optional<UriRouteMatch<T,R>> |
DELETE(CharSequence uri)
Find the first
RouteMatch route for an HttpMethod.DELETE method and the given URI. |
<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>> |
find(HttpMethod httpMethod,
CharSequence uri,
HttpRequest<?> context)
Finds all of the possible routes for the given HTTP method and URI.
|
<T,R> Stream<UriRouteMatch<T,R>> |
find(HttpMethod httpMethod,
URI uri)
Finds all of the possible routes for the given HTTP method and URI.
|
<T,R> Stream<UriRouteMatch<T,R>> |
find(HttpRequest<?> request)
Finds all of the possible routes for the given HTTP request.
|
<T,R> List<UriRouteMatch<T,R>> |
findAllClosest(HttpRequest<?> request)
Finds the closest match for the given request.
|
<T,R> Stream<UriRouteMatch<T,R>> |
findAny(CharSequence uri)
Find any
RouteMatch regardless of HTTP method. |
<T,R> Stream<UriRouteMatch<T,R>> |
findAny(CharSequence uri,
HttpRequest<?> context)
Find any
RouteMatch regardless of HTTP method. |
List<HttpFilter> |
findFilters(HttpRequest<?> request)
Build a filtered
Publisher for an action. |
<T,R> Optional<UriRouteMatch<T,R>> |
GET(CharSequence uri)
Find the first
RouteMatch route for an HttpMethod.GET method and the given URI. |
<T,R> Optional<UriRouteMatch<T,R>> |
HEAD(CharSequence uri)
Find the first
RouteMatch route for an HttpMethod.HEAD method and the given URI. |
<T,R> Optional<UriRouteMatch<T,R>> |
OPTIONS(CharSequence uri)
Find the first
RouteMatch route for an HttpMethod.OPTIONS method and the given URI. |
<T,R> Optional<UriRouteMatch<T,R>> |
PATCH(CharSequence uri)
Find the first
RouteMatch route for an HttpMethod.PATCH method and the given URI. |
<T,R> Optional<UriRouteMatch<T,R>> |
POST(CharSequence uri)
Find the first
RouteMatch route for an HttpMethod.POST method and the given URI. |
<T,R> Optional<UriRouteMatch<T,R>> |
PUT(CharSequence uri)
Find the first
RouteMatch route for an HttpMethod.PUT method and the given URI. |
<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.
|
public FilteredRouter(Router router, RouteMatchFilter routeFilter)
RouteMatchFilter
.router
- A Router
to delegate torouteFilter
- A RouteMatchFilter
to filter non matching routes@Nonnull public <T,R> Stream<UriRouteMatch<T,R>> findAny(@Nonnull CharSequence uri)
Router
RouteMatch
regardless of HTTP method.@Nonnull public <T,R> Stream<UriRouteMatch<T,R>> findAny(@Nonnull CharSequence uri, @Nullable HttpRequest<?> context)
Router
RouteMatch
regardless of HTTP method.findAny
in interface Router
T
- The target typeR
- The return typeuri
- The URIcontext
- The optional HttpRequest
context information to apply RouteMatchFilter
.@Nonnull public <T,R> Stream<UriRouteMatch<T,R>> find(@Nonnull HttpMethod httpMethod, @Nonnull CharSequence uri)
Router
@Nonnull public <T,R> Stream<UriRouteMatch<T,R>> find(@Nonnull HttpMethod httpMethod, @Nonnull CharSequence uri, @Nullable HttpRequest<?> context)
Router
find
in interface Router
T
- The target typeR
- The typehttpMethod
- The HTTP methoduri
- The URI route matchcontext
- The optional HttpRequest
context information to apply RouteMatchFilter
.Stream
of possible Route
instances.@Nonnull public <T,R> List<UriRouteMatch<T,R>> findAllClosest(@Nonnull HttpRequest<?> request)
Router
findAllClosest
in interface Router
T
- The target typeR
- The typerequest
- The requestList
of possible Route
instances.@Nonnull public Stream<UriRoute> uriRoutes()
Router
public <T,R> Optional<UriRouteMatch<T,R>> route(@Nonnull HttpMethod httpMethod, @Nonnull CharSequence uri)
Router
public <R> Optional<RouteMatch<R>> route(@Nonnull 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(@Nonnull Class originatingClass, @Nonnull 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(@Nonnull Throwable error)
Router
route
in interface Router
R
- The matched routeerror
- The errorRouteMatch
public <R> Optional<RouteMatch<R>> route(@Nonnull Class originatingClass, @Nonnull Throwable error)
Router
route
in interface Router
R
- The matched routeoriginatingClass
- The class the error originates fromerror
- The errorRouteMatch
@Nonnull public List<HttpFilter> findFilters(@Nonnull HttpRequest<?> request)
Router
Publisher
for an action.findFilters
in interface Router
request
- The requestpublic <T,R> Optional<UriRouteMatch<T,R>> GET(@Nonnull CharSequence uri)
Router
RouteMatch
route for an HttpMethod.GET
method and the given URI.GET
in interface Router
T
- The target typeR
- The return typeuri
- The URIOptional
of RouteMatch
public <T,R> Optional<UriRouteMatch<T,R>> POST(@Nonnull CharSequence uri)
Router
RouteMatch
route for an HttpMethod.POST
method and the given URI.POST
in interface Router
T
- The target typeR
- The return typeuri
- The URIOptional
of RouteMatch
public <T,R> Optional<UriRouteMatch<T,R>> PUT(@Nonnull CharSequence uri)
Router
RouteMatch
route for an HttpMethod.PUT
method and the given URI.PUT
in interface Router
T
- The target typeR
- The URI route matchuri
- The URIOptional
of RouteMatch
public <T,R> Optional<UriRouteMatch<T,R>> PATCH(@Nonnull CharSequence uri)
Router
RouteMatch
route for an HttpMethod.PATCH
method and the given URI.PATCH
in interface Router
T
- The target typeR
- The return typeuri
- The URIOptional
of RouteMatch
public <T,R> Optional<UriRouteMatch<T,R>> DELETE(@Nonnull CharSequence uri)
Router
RouteMatch
route for an HttpMethod.DELETE
method and the given URI.DELETE
in interface Router
T
- The target typeR
- The return typeuri
- The URIOptional
of RouteMatch
public <T,R> Optional<UriRouteMatch<T,R>> OPTIONS(@Nonnull CharSequence uri)
Router
RouteMatch
route for an HttpMethod.OPTIONS
method and the given URI.OPTIONS
in interface Router
T
- The target typeR
- The return typeuri
- The URIOptional
of RouteMatch
public <T,R> Optional<UriRouteMatch<T,R>> HEAD(@Nonnull CharSequence uri)
Router
RouteMatch
route for an HttpMethod.HEAD
method and the given URI.HEAD
in interface Router
T
- The target typeR
- The return typeuri
- The URIOptional
of RouteMatch
@Nonnull public <T,R> Stream<UriRouteMatch<T,R>> find(@Nonnull HttpMethod httpMethod, @Nonnull URI uri)
Router
@Nonnull public <T,R> Stream<UriRouteMatch<T,R>> find(@Nonnull HttpRequest<?> request)
Router