Package io.micronaut.web.router
Interface Router
-
- All Known Implementing Classes:
DefaultRouter,FilteredRouter
public interface RouterCore Router interface that allows discovery of a route given an HTTP method and URI.
- Since:
- 1.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidapplyDefaultPorts(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 firstRouteMatchroute for anHttpMethod.DELETEmethod and the given URI.<T,R>
java.util.stream.Stream<UriRouteMatch<T,R>>find(io.micronaut.http.HttpMethod httpMethod, java.lang.CharSequence uri, io.micronaut.http.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(io.micronaut.http.HttpMethod httpMethod, java.net.URI uri, io.micronaut.http.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(io.micronaut.http.HttpRequest<?> request)Finds all of the possible routes for the given HTTP request.default <T,R>
java.util.stream.Stream<UriRouteMatch<T,R>>find(io.micronaut.http.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(io.micronaut.http.HttpRequest<?> request)Finds the closest match for the given request.<T,R>
java.util.stream.Stream<UriRouteMatch<T,R>>findAny(java.lang.CharSequence uri, io.micronaut.http.HttpRequest<?> context)Find anyRouteMatchregardless of HTTP method.<R> java.util.Optional<RouteMatch<R>>findErrorRoute(java.lang.Class<?> originatingClass, java.lang.Throwable error, io.micronaut.http.HttpRequest<?> request)Match a route to an error.<R> java.util.Optional<RouteMatch<R>>findErrorRoute(java.lang.Throwable error, io.micronaut.http.HttpRequest<?> request)Match a route to an error.java.util.List<io.micronaut.http.filter.HttpFilter>findFilters(io.micronaut.http.HttpRequest<?> request)Build a filteredPublisherfor an action.<R> java.util.Optional<RouteMatch<R>>findStatusRoute(io.micronaut.http.HttpStatus status, io.micronaut.http.HttpRequest<?> request)Found aRouteMatchfor the givenHttpStatuscode.<R> java.util.Optional<RouteMatch<R>>findStatusRoute(java.lang.Class<?> originatingClass, io.micronaut.http.HttpStatus status, io.micronaut.http.HttpRequest<?> request)Found aRouteMatchfor the givenHttpStatuscode.default <T,R>
java.util.Optional<UriRouteMatch<T,R>>GET(java.lang.CharSequence uri)Find the firstRouteMatchroute for anHttpMethod.GETmethod 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 firstRouteMatchroute for anHttpMethod.HEADmethod and the given URI.default <T,R>
java.util.Optional<UriRouteMatch<T,R>>OPTIONS(java.lang.CharSequence uri)Find the firstRouteMatchroute for anHttpMethod.OPTIONSmethod and the given URI.default <T,R>
java.util.Optional<UriRouteMatch<T,R>>PATCH(java.lang.CharSequence uri)Find the firstRouteMatchroute for anHttpMethod.PATCHmethod and the given URI.default <T,R>
java.util.Optional<UriRouteMatch<T,R>>POST(java.lang.CharSequence uri)Find the firstRouteMatchroute for anHttpMethod.POSTmethod and the given URI.default <T,R>
java.util.Optional<UriRouteMatch<T,R>>PUT(java.lang.CharSequence uri)Find the firstRouteMatchroute for anHttpMethod.PUTmethod and the given URI.<T,R>
java.util.Optional<UriRouteMatch<T,R>>route(io.micronaut.http.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(io.micronaut.http.HttpStatus status)Found aRouteMatchfor the givenHttpStatuscode.<R> java.util.Optional<RouteMatch<R>>route(java.lang.Class originatingClass, io.micronaut.http.HttpStatus status)Found aRouteMatchfor the givenHttpStatuscode.<R> java.util.Optional<RouteMatch<R>>route(java.lang.Class originatingClass, java.lang.Throwable error)Match a route to an error.<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.
-
-
-
Method Detail
-
findAny
@NonNull <T,R> java.util.stream.Stream<UriRouteMatch<T,R>> findAny(@NonNull java.lang.CharSequence uri, @Nullable io.micronaut.http.HttpRequest<?> context)
Find anyRouteMatchregardless of HTTP method.- Type Parameters:
T- The target typeR- The return type- Parameters:
uri- The URIcontext- The optionalHttpRequestcontext information to applyRouteMatchFilter.- Returns:
- A stream of route matches
-
getExposedPorts
java.util.Set<java.lang.Integer> getExposedPorts()
- Returns:
- The exposed ports.
-
applyDefaultPorts
void applyDefaultPorts(java.util.List<java.lang.Integer> ports)
Sets the ports the application will listen to by default.- Parameters:
ports- The default ports
-
find
@NonNull <T,R> java.util.stream.Stream<UriRouteMatch<T,R>> find(@NonNull io.micronaut.http.HttpMethod httpMethod, @NonNull java.lang.CharSequence uri, @Nullable io.micronaut.http.HttpRequest<?> context)
Finds all of the possible routes for the given HTTP method and URI.- Type Parameters:
T- The target typeR- The type- Parameters:
httpMethod- The HTTP methoduri- The URI route matchcontext- The optionalHttpRequestcontext information to applyRouteMatchFilter.- Returns:
- A
Streamof possibleRouteinstances.
-
find
@NonNull default <T,R> java.util.stream.Stream<UriRouteMatch<T,R>> find(@NonNull io.micronaut.http.HttpMethod httpMethod, @NonNull java.net.URI uri, @Nullable io.micronaut.http.HttpRequest<?> context)
Finds all of the possible routes for the given HTTP method and URI.- Type Parameters:
T- The target typeR- The URI route match- Parameters:
httpMethod- The HTTP methoduri- The URIcontext- The optionalHttpRequestcontext- Returns:
- A
Streamof possibleRouteinstances.
-
find
@NonNull default <T,R> java.util.stream.Stream<UriRouteMatch<T,R>> find(@NonNull io.micronaut.http.HttpRequest<?> request)
Finds all of the possible routes for the given HTTP request.- Type Parameters:
T- The target typeR- The URI route match- Parameters:
request- The HTTP request- Returns:
- A
Streamof possibleRouteinstances.
-
find
@NonNull default <T,R> java.util.stream.Stream<UriRouteMatch<T,R>> find(@NonNull io.micronaut.http.HttpRequest<?> request, @NonNull java.lang.CharSequence uri)
Find method, that should be used for non-standard http methods. For standards it should act the same asfind(HttpMethod, CharSequence, HttpRequest)- Type Parameters:
T- The target type.R- The type of what- Parameters:
request- The request, that can have overriddenHttpRequest.getMethodName()uri- The URI route match.- Returns:
- A
Streamof possibleRouteinstances.
-
findAllClosest
@NonNull <T,R> java.util.List<UriRouteMatch<T,R>> findAllClosest(@NonNull io.micronaut.http.HttpRequest<?> request)
Finds the closest match for the given request.- Type Parameters:
T- The target typeR- The type- Parameters:
request- The request- Returns:
- A
Listof possibleRouteinstances. - Since:
- 1.2.1
-
uriRoutes
@NonNull java.util.stream.Stream<UriRoute> uriRoutes()
Returns all UriRoutes.- Returns:
- A
Streamof all registeredUriRouteinstances.
-
route
<T,R> java.util.Optional<UriRouteMatch<T,R>> route(@NonNull io.micronaut.http.HttpMethod httpMethod, @NonNull java.lang.CharSequence uri)
Finds the first possible route for the given HTTP method and URI.- Type Parameters:
T- The target typeR- The URI route match- Parameters:
httpMethod- The HTTP methoduri- The URI- Returns:
- The route match
-
route
<R> java.util.Optional<RouteMatch<R>> route(@NonNull io.micronaut.http.HttpStatus status)
Found aRouteMatchfor the givenHttpStatuscode.- Type Parameters:
R- The matched route- Parameters:
status- The HTTP status- Returns:
- The
RouteMatch
-
route
<R> java.util.Optional<RouteMatch<R>> route(@NonNull java.lang.Class originatingClass, @NonNull io.micronaut.http.HttpStatus status)
Found aRouteMatchfor the givenHttpStatuscode.- Type Parameters:
R- The matched route- Parameters:
originatingClass- The class the error originates fromstatus- The HTTP status- Returns:
- The
RouteMatch
-
route
<R> java.util.Optional<RouteMatch<R>> route(@NonNull java.lang.Throwable error)
Match a route to an error.- Type Parameters:
R- The matched route- Parameters:
error- The error- Returns:
- The
RouteMatch
-
route
<R> java.util.Optional<RouteMatch<R>> route(@NonNull java.lang.Class originatingClass, @NonNull java.lang.Throwable error)
Match a route to an error.- Type Parameters:
R- The matched route- Parameters:
originatingClass- The class the error originates fromerror- The error- Returns:
- The
RouteMatch
-
findErrorRoute
<R> java.util.Optional<RouteMatch<R>> findErrorRoute(@NonNull java.lang.Class<?> originatingClass, @NonNull java.lang.Throwable error, io.micronaut.http.HttpRequest<?> request)
Match a route to an error.- Type Parameters:
R- The matched route- Parameters:
originatingClass- The class the error originates fromerror- The errorrequest- The request- Returns:
- The
RouteMatch
-
findErrorRoute
<R> java.util.Optional<RouteMatch<R>> findErrorRoute(@NonNull java.lang.Throwable error, io.micronaut.http.HttpRequest<?> request)
Match a route to an error.- Type Parameters:
R- The matched route- Parameters:
error- The errorrequest- The request- Returns:
- The
RouteMatch
-
findStatusRoute
<R> java.util.Optional<RouteMatch<R>> findStatusRoute(@NonNull java.lang.Class<?> originatingClass, @NonNull io.micronaut.http.HttpStatus status, io.micronaut.http.HttpRequest<?> request)
Found aRouteMatchfor the givenHttpStatuscode.- Type Parameters:
R- The matched route- Parameters:
originatingClass- The class the error originates fromstatus- The HTTP statusrequest- The request- Returns:
- The
RouteMatch
-
findStatusRoute
<R> java.util.Optional<RouteMatch<R>> findStatusRoute(@NonNull io.micronaut.http.HttpStatus status, io.micronaut.http.HttpRequest<?> request)
Found aRouteMatchfor the givenHttpStatuscode.- Type Parameters:
R- The matched route- Parameters:
status- The HTTP statusrequest- The request- Returns:
- The
RouteMatch
-
findFilters
@NonNull java.util.List<io.micronaut.http.filter.HttpFilter> findFilters(@NonNull io.micronaut.http.HttpRequest<?> request)Build a filteredPublisherfor an action.- Parameters:
request- The request- Returns:
- A new filtered publisher
-
GET
default <T,R> java.util.Optional<UriRouteMatch<T,R>> GET(@NonNull java.lang.CharSequence uri)
Find the firstRouteMatchroute for anHttpMethod.GETmethod and the given URI.- Type Parameters:
T- The target typeR- The return type- Parameters:
uri- The URI- Returns:
- An
OptionalofRouteMatch
-
POST
default <T,R> java.util.Optional<UriRouteMatch<T,R>> POST(@NonNull java.lang.CharSequence uri)
Find the firstRouteMatchroute for anHttpMethod.POSTmethod and the given URI.- Type Parameters:
T- The target typeR- The return type- Parameters:
uri- The URI- Returns:
- An
OptionalofRouteMatch
-
PUT
default <T,R> java.util.Optional<UriRouteMatch<T,R>> PUT(@NonNull java.lang.CharSequence uri)
Find the firstRouteMatchroute for anHttpMethod.PUTmethod and the given URI.- Type Parameters:
T- The target typeR- The URI route match- Parameters:
uri- The URI- Returns:
- An
OptionalofRouteMatch
-
PATCH
default <T,R> java.util.Optional<UriRouteMatch<T,R>> PATCH(@NonNull java.lang.CharSequence uri)
Find the firstRouteMatchroute for anHttpMethod.PATCHmethod and the given URI.- Type Parameters:
T- The target typeR- The return type- Parameters:
uri- The URI- Returns:
- An
OptionalofRouteMatch
-
DELETE
default <T,R> java.util.Optional<UriRouteMatch<T,R>> DELETE(@NonNull java.lang.CharSequence uri)
Find the firstRouteMatchroute for anHttpMethod.DELETEmethod and the given URI.- Type Parameters:
T- The target typeR- The return type- Parameters:
uri- The URI- Returns:
- An
OptionalofRouteMatch
-
OPTIONS
default <T,R> java.util.Optional<UriRouteMatch<T,R>> OPTIONS(@NonNull java.lang.CharSequence uri)
Find the firstRouteMatchroute for anHttpMethod.OPTIONSmethod and the given URI.- Type Parameters:
T- The target typeR- The return type- Parameters:
uri- The URI- Returns:
- An
OptionalofRouteMatch
-
HEAD
default <T,R> java.util.Optional<UriRouteMatch<T,R>> HEAD(@NonNull java.lang.CharSequence uri)
Find the firstRouteMatchroute for anHttpMethod.HEADmethod and the given URI.- Type Parameters:
T- The target typeR- The return type- Parameters:
uri- The URI- Returns:
- An
OptionalofRouteMatch
-
-