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 |
|---|---|
void |
applyDefaultPorts(List<Integer> ports)
Sets the ports the application will listen to by default.
|
<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,
HttpRequest<?> context)
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> Stream<UriRouteMatch<T,R>> |
find(HttpRequest<?> request,
CharSequence uri)
Find method, that should be used for non-standard http methods.
|
<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,
HttpRequest<?> context)
Find any
RouteMatch regardless of HTTP method. |
<R> Optional<RouteMatch<R>> |
findErrorRoute(Class<?> originatingClass,
Throwable error,
HttpRequest<?> request)
Match a route to an error.
|
<R> Optional<RouteMatch<R>> |
findErrorRoute(Throwable error,
HttpRequest<?> request)
Match a route to an error.
|
List<HttpFilter> |
findFilters(HttpRequest<?> request)
Build a filtered
Publisher for an action. |
<R> Optional<RouteMatch<R>> |
findStatusRoute(Class<?> originatingClass,
HttpStatus status,
HttpRequest<?> request)
Found a
RouteMatch for the given HttpStatus code. |
<R> Optional<RouteMatch<R>> |
findStatusRoute(HttpStatus status,
HttpRequest<?> request)
Found a
RouteMatch for the given HttpStatus code. |
<T,R> Optional<UriRouteMatch<T,R>> |
GET(CharSequence uri)
Find the first
RouteMatch route for an HttpMethod.GET method and the given URI. |
Set<Integer> |
getExposedPorts() |
<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, @Nullable HttpRequest<?> context)
RouterRouteMatch regardless of HTTP method.findAny in interface RouterT - The target typeR - The return typeuri - The URIcontext - The optional HttpRequest context information to apply RouteMatchFilter.public Set<Integer> getExposedPorts()
getExposedPorts in interface Routerpublic void applyDefaultPorts(List<Integer> ports)
RouterapplyDefaultPorts in interface Routerports - The default ports@NonNull public <T,R> Stream<UriRouteMatch<T,R>> find(@NonNull HttpMethod httpMethod, @NonNull CharSequence uri, @Nullable HttpRequest<?> context)
Routerfind in interface RouterT - 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)
RouterfindAllClosest in interface RouterT - The target typeR - The typerequest - The requestList of possible Route instances.@NonNull public <T,R> Stream<UriRouteMatch<T,R>> find(@NonNull HttpRequest<?> request, @NonNull CharSequence uri)
RouterRouter.find(HttpMethod, CharSequence, HttpRequest)find in interface RouterT - The target type.R - The type of whatrequest - The request, that can have overridden HttpRequest.getMethodName()uri - The URI route match.Stream of possible Route instances.@NonNull public Stream<UriRoute> uriRoutes()
Routerpublic <T,R> Optional<UriRouteMatch<T,R>> route(@NonNull HttpMethod httpMethod, @NonNull CharSequence uri)
Routerpublic <R> Optional<RouteMatch<R>> route(@NonNull HttpStatus status)
RouterRouteMatch for the given HttpStatus code.route in interface RouterR - The matched routestatus - The HTTP statusRouteMatchpublic <R> Optional<RouteMatch<R>> route(@NonNull Class originatingClass, @NonNull HttpStatus status)
RouterRouteMatch for the given HttpStatus code.route in interface RouterR - The matched routeoriginatingClass - The class the error originates fromstatus - The HTTP statusRouteMatchpublic <R> Optional<RouteMatch<R>> route(@NonNull Throwable error)
Routerroute in interface RouterR - The matched routeerror - The errorRouteMatchpublic <R> Optional<RouteMatch<R>> route(@NonNull Class originatingClass, @NonNull Throwable error)
Routerroute in interface RouterR - The matched routeoriginatingClass - The class the error originates fromerror - The errorRouteMatchpublic <R> Optional<RouteMatch<R>> findErrorRoute(@NonNull Class<?> originatingClass, @NonNull Throwable error, HttpRequest<?> request)
RouterfindErrorRoute in interface RouterR - The matched routeoriginatingClass - The class the error originates fromerror - The errorrequest - The requestRouteMatchpublic <R> Optional<RouteMatch<R>> findErrorRoute(@NonNull Throwable error, HttpRequest<?> request)
RouterfindErrorRoute in interface RouterR - The matched routeerror - The errorrequest - The requestRouteMatchpublic <R> Optional<RouteMatch<R>> findStatusRoute(@NonNull Class<?> originatingClass, @NonNull HttpStatus status, HttpRequest<?> request)
RouterRouteMatch for the given HttpStatus code.findStatusRoute in interface RouterR - The matched routeoriginatingClass - The class the error originates fromstatus - The HTTP statusrequest - The requestRouteMatchpublic <R> Optional<RouteMatch<R>> findStatusRoute(@NonNull HttpStatus status, HttpRequest<?> request)
RouterRouteMatch for the given HttpStatus code.findStatusRoute in interface RouterR - The matched routestatus - The HTTP statusrequest - The requestRouteMatch@NonNull public List<HttpFilter> findFilters(@NonNull HttpRequest<?> request)
RouterPublisher for an action.findFilters in interface Routerrequest - The requestpublic <T,R> Optional<UriRouteMatch<T,R>> GET(@NonNull CharSequence uri)
RouterRouteMatch route for an HttpMethod.GET method and the given URI.GET in interface RouterT - The target typeR - The return typeuri - The URIOptional of RouteMatchpublic <T,R> Optional<UriRouteMatch<T,R>> POST(@NonNull CharSequence uri)
RouterRouteMatch route for an HttpMethod.POST method and the given URI.POST in interface RouterT - The target typeR - The return typeuri - The URIOptional of RouteMatchpublic <T,R> Optional<UriRouteMatch<T,R>> PUT(@NonNull CharSequence uri)
RouterRouteMatch route for an HttpMethod.PUT method and the given URI.PUT in interface RouterT - The target typeR - The URI route matchuri - The URIOptional of RouteMatchpublic <T,R> Optional<UriRouteMatch<T,R>> PATCH(@NonNull CharSequence uri)
RouterRouteMatch route for an HttpMethod.PATCH method and the given URI.PATCH in interface RouterT - The target typeR - The return typeuri - The URIOptional of RouteMatchpublic <T,R> Optional<UriRouteMatch<T,R>> DELETE(@NonNull CharSequence uri)
RouterRouteMatch route for an HttpMethod.DELETE method and the given URI.DELETE in interface RouterT - The target typeR - The return typeuri - The URIOptional of RouteMatchpublic <T,R> Optional<UriRouteMatch<T,R>> OPTIONS(@NonNull CharSequence uri)
RouterRouteMatch route for an HttpMethod.OPTIONS method and the given URI.OPTIONS in interface RouterT - The target typeR - The return typeuri - The URIOptional of RouteMatchpublic <T,R> Optional<UriRouteMatch<T,R>> HEAD(@NonNull CharSequence uri)
RouterRouteMatch route for an HttpMethod.HEAD method and the given URI.HEAD in interface RouterT - The target typeR - The return typeuri - The URIOptional of RouteMatch@NonNull public <T,R> Stream<UriRouteMatch<T,R>> find(@NonNull HttpRequest<?> request)
Router