public interface Router
Core Router interface that allows discovery of a route given an HTTP method and URI.
Modifier and Type | Method and Description |
---|---|
void |
applyDefaultPorts(java.util.List<java.lang.Integer> ports)
Sets the ports the application will listen to by default.
|
default <T,R> java.util.Optional<UriRouteMatch<T,R>> |
DELETE(java.lang.CharSequence uri)
Find the first
RouteMatch route for an HttpMethod.DELETE method and the given URI. |
<T,R> java.util.stream.Stream<UriRouteMatch<T,R>> |
find(HttpMethod httpMethod,
java.lang.CharSequence uri,
HttpRequest<?> context)
Finds all of the possible routes for the given HTTP method and URI.
|
default <T,R> java.util.stream.Stream<UriRouteMatch<T,R>> |
find(HttpMethod httpMethod,
java.net.URI uri,
HttpRequest<?> context)
Finds all of the possible routes for the given HTTP method and URI.
|
default <T,R> java.util.stream.Stream<UriRouteMatch<T,R>> |
find(HttpRequest<?> request)
Finds all of the possible routes for the given HTTP request.
|
default <T,R> java.util.stream.Stream<UriRouteMatch<T,R>> |
find(HttpRequest<?> request,
java.lang.CharSequence uri)
Find method, that should be used for non-standard http methods.
|
<T,R> java.util.List<UriRouteMatch<T,R>> |
findAllClosest(HttpRequest<?> request)
Finds the closest match for the given request.
|
<T,R> java.util.stream.Stream<UriRouteMatch<T,R>> |
findAny(java.lang.CharSequence uri,
HttpRequest<?> context)
Find any
RouteMatch regardless of HTTP method. |
<R> java.util.Optional<RouteMatch<R>> |
findErrorRoute(java.lang.Class<?> originatingClass,
java.lang.Throwable error,
HttpRequest<?> request)
Match a route to an error.
|
<R> java.util.Optional<RouteMatch<R>> |
findErrorRoute(java.lang.Throwable error,
HttpRequest<?> request)
Match a route to an error.
|
java.util.List<HttpFilter> |
findFilters(HttpRequest<?> request)
Build a filtered
Publisher for an action. |
<R> java.util.Optional<RouteMatch<R>> |
findStatusRoute(java.lang.Class<?> originatingClass,
HttpStatus status,
HttpRequest<?> request)
Found a
RouteMatch for the given HttpStatus code. |
<R> java.util.Optional<RouteMatch<R>> |
findStatusRoute(HttpStatus status,
HttpRequest<?> request)
Found a
RouteMatch for the given HttpStatus code. |
default <T,R> java.util.Optional<UriRouteMatch<T,R>> |
GET(java.lang.CharSequence uri)
Find the first
RouteMatch route for an HttpMethod.GET method and the given URI. |
java.util.Set<java.lang.Integer> |
getExposedPorts() |
default <T,R> java.util.Optional<UriRouteMatch<T,R>> |
HEAD(java.lang.CharSequence uri)
Find the first
RouteMatch route for an HttpMethod.HEAD method and the given URI. |
default <T,R> java.util.Optional<UriRouteMatch<T,R>> |
OPTIONS(java.lang.CharSequence uri)
Find the first
RouteMatch route for an HttpMethod.OPTIONS method and the given URI. |
default <T,R> java.util.Optional<UriRouteMatch<T,R>> |
PATCH(java.lang.CharSequence uri)
Find the first
RouteMatch route for an HttpMethod.PATCH method and the given URI. |
default <T,R> java.util.Optional<UriRouteMatch<T,R>> |
POST(java.lang.CharSequence uri)
Find the first
RouteMatch route for an HttpMethod.POST method and the given URI. |
default <T,R> java.util.Optional<UriRouteMatch<T,R>> |
PUT(java.lang.CharSequence uri)
Find the first
RouteMatch route for an HttpMethod.PUT method and the given URI. |
<R> java.util.Optional<RouteMatch<R>> |
route(java.lang.Class originatingClass,
HttpStatus status)
Found a
RouteMatch for the given HttpStatus code. |
<R> java.util.Optional<RouteMatch<R>> |
route(java.lang.Class originatingClass,
java.lang.Throwable error)
Match a route to an error.
|
<T,R> java.util.Optional<UriRouteMatch<T,R>> |
route(HttpMethod httpMethod,
java.lang.CharSequence uri)
Finds the first possible route for the given HTTP method and URI.
|
<R> java.util.Optional<RouteMatch<R>> |
route(HttpStatus status)
Found a
RouteMatch for the given HttpStatus code. |
<R> java.util.Optional<RouteMatch<R>> |
route(java.lang.Throwable error)
Match a route to an error.
|
java.util.stream.Stream<UriRoute> |
uriRoutes()
Returns all UriRoutes.
|
@NonNull <T,R> java.util.stream.Stream<UriRouteMatch<T,R>> findAny(@NonNull java.lang.CharSequence uri, @Nullable HttpRequest<?> context)
RouteMatch
regardless of HTTP method.T
- The target typeR
- The return typeuri
- The URIcontext
- The optional HttpRequest
context information to apply RouteMatchFilter
.java.util.Set<java.lang.Integer> getExposedPorts()
void applyDefaultPorts(java.util.List<java.lang.Integer> ports)
ports
- The default ports@NonNull <T,R> java.util.stream.Stream<UriRouteMatch<T,R>> find(@NonNull HttpMethod httpMethod, @NonNull java.lang.CharSequence uri, @Nullable HttpRequest<?> context)
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 default <T,R> java.util.stream.Stream<UriRouteMatch<T,R>> find(@NonNull HttpMethod httpMethod, @NonNull java.net.URI uri, @Nullable HttpRequest<?> context)
T
- The target typeR
- The URI route matchhttpMethod
- The HTTP methoduri
- The URIcontext
- The optional HttpRequest
contextStream
of possible Route
instances.@NonNull default <T,R> java.util.stream.Stream<UriRouteMatch<T,R>> find(@NonNull HttpRequest<?> request)
T
- The target typeR
- The URI route matchrequest
- The HTTP requestStream
of possible Route
instances.@NonNull default <T,R> java.util.stream.Stream<UriRouteMatch<T,R>> find(@NonNull HttpRequest<?> request, @NonNull java.lang.CharSequence uri)
find(HttpMethod, CharSequence, HttpRequest)
T
- 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 <T,R> java.util.List<UriRouteMatch<T,R>> findAllClosest(@NonNull HttpRequest<?> request)
T
- The target typeR
- The typerequest
- The requestList
of possible Route
instances.@NonNull java.util.stream.Stream<UriRoute> uriRoutes()
Stream
of all registered UriRoute
instances.<T,R> java.util.Optional<UriRouteMatch<T,R>> route(@NonNull HttpMethod httpMethod, @NonNull java.lang.CharSequence uri)
T
- The target typeR
- The URI route matchhttpMethod
- The HTTP methoduri
- The URI<R> java.util.Optional<RouteMatch<R>> route(@NonNull HttpStatus status)
RouteMatch
for the given HttpStatus
code.R
- The matched routestatus
- The HTTP statusRouteMatch
<R> java.util.Optional<RouteMatch<R>> route(@NonNull java.lang.Class originatingClass, @NonNull HttpStatus status)
RouteMatch
for the given HttpStatus
code.R
- The matched routeoriginatingClass
- The class the error originates fromstatus
- The HTTP statusRouteMatch
<R> java.util.Optional<RouteMatch<R>> route(@NonNull java.lang.Throwable error)
R
- The matched routeerror
- The errorRouteMatch
<R> java.util.Optional<RouteMatch<R>> route(@NonNull java.lang.Class originatingClass, @NonNull java.lang.Throwable error)
R
- The matched routeoriginatingClass
- The class the error originates fromerror
- The errorRouteMatch
<R> java.util.Optional<RouteMatch<R>> findErrorRoute(@NonNull java.lang.Class<?> originatingClass, @NonNull java.lang.Throwable error, HttpRequest<?> request)
R
- The matched routeoriginatingClass
- The class the error originates fromerror
- The errorrequest
- The requestRouteMatch
<R> java.util.Optional<RouteMatch<R>> findErrorRoute(@NonNull java.lang.Throwable error, HttpRequest<?> request)
R
- The matched routeerror
- The errorrequest
- The requestRouteMatch
<R> java.util.Optional<RouteMatch<R>> findStatusRoute(@NonNull java.lang.Class<?> originatingClass, @NonNull HttpStatus status, HttpRequest<?> request)
RouteMatch
for the given HttpStatus
code.R
- The matched routeoriginatingClass
- The class the error originates fromstatus
- The HTTP statusrequest
- The requestRouteMatch
<R> java.util.Optional<RouteMatch<R>> findStatusRoute(@NonNull HttpStatus status, HttpRequest<?> request)
RouteMatch
for the given HttpStatus
code.R
- The matched routestatus
- The HTTP statusrequest
- The requestRouteMatch
@NonNull java.util.List<HttpFilter> findFilters(@NonNull HttpRequest<?> request)
Publisher
for an action.request
- The requestdefault <T,R> java.util.Optional<UriRouteMatch<T,R>> GET(@NonNull java.lang.CharSequence uri)
RouteMatch
route for an HttpMethod.GET
method and the given URI.T
- The target typeR
- The return typeuri
- The URIOptional
of RouteMatch
default <T,R> java.util.Optional<UriRouteMatch<T,R>> POST(@NonNull java.lang.CharSequence uri)
RouteMatch
route for an HttpMethod.POST
method and the given URI.T
- The target typeR
- The return typeuri
- The URIOptional
of RouteMatch
default <T,R> java.util.Optional<UriRouteMatch<T,R>> PUT(@NonNull java.lang.CharSequence uri)
RouteMatch
route for an HttpMethod.PUT
method and the given URI.T
- The target typeR
- The URI route matchuri
- The URIOptional
of RouteMatch
default <T,R> java.util.Optional<UriRouteMatch<T,R>> PATCH(@NonNull java.lang.CharSequence uri)
RouteMatch
route for an HttpMethod.PATCH
method and the given URI.T
- The target typeR
- The return typeuri
- The URIOptional
of RouteMatch
default <T,R> java.util.Optional<UriRouteMatch<T,R>> DELETE(@NonNull java.lang.CharSequence uri)
RouteMatch
route for an HttpMethod.DELETE
method and the given URI.T
- The target typeR
- The return typeuri
- The URIOptional
of RouteMatch
default <T,R> java.util.Optional<UriRouteMatch<T,R>> OPTIONS(@NonNull java.lang.CharSequence uri)
RouteMatch
route for an HttpMethod.OPTIONS
method and the given URI.T
- The target typeR
- The return typeuri
- The URIOptional
of RouteMatch
default <T,R> java.util.Optional<UriRouteMatch<T,R>> HEAD(@NonNull java.lang.CharSequence uri)
RouteMatch
route for an HttpMethod.HEAD
method and the given URI.T
- The target typeR
- The return typeuri
- The URIOptional
of RouteMatch