public sealed interface Routing
Routing abstraction.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceA routing entry.static interfaceAdds to the Routing.static enumThe type of route entry. -
Method Summary
Modifier and TypeMethodDescriptionadd(Routing.HttpService service) Add the routes provided by the given HttpService.addAll(Collection<Routing.HttpService> routes) Add all the routes provided by the Routing Services.default RoutingAdd a post-processing filter for all matched requests.default RoutingAdd a pre-processing filter for all matched requests.delete(String path, ExchangeHandler handler, Role... roles) Adds a DELETE handler to the route configuration.error(Class<T> exceptionClass, ExceptionHandler<T> handler) Registers an exception handler that handles the given type of exceptions.Map<Class<?>, ExceptionHandler<?>> Return all the registered Exception Handlers.filter(HttpFilter handler) Add a filter for all matched requests.filters()Return all the registered filters.get(String path, ExchangeHandler handler, Role... roles) Adds a GET handler to the route configuration.group(String path, Routing.HttpService group) Add a group of route handlers with a common path prefix.handlers()Return all the registered handlers.head(String path, ExchangeHandler handler, Role... roles) Adds a HEAD handler to the route configuration.options(String path, ExchangeHandler handler, Role... roles) Adds an OPTIONS handler to the route configuration.patch(String path, ExchangeHandler handler, Role... roles) Adds a PATCH handler to the route configuration.post(String path, ExchangeHandler handler, Role... roles) Adds a POST handler to the route configuration.put(String path, ExchangeHandler handler, Role... roles) Adds a PUT handler to the route configuration.trace(String path, ExchangeHandler handler, Role... roles) Adds a TRACE handler to the route configuration.
-
Method Details
-
add
Add the routes provided by the given HttpService. -
addAll
Add all the routes provided by the Routing Services. -
error
Registers an exception handler that handles the given type of exceptions. This will replace an existing error handler for the same exception class.- Type Parameters:
T- exception type- Parameters:
exceptionClass- the type of exception to handle by this handlerhandler- the error handler
-
group
Add a group of route handlers with a common path prefix.routing.path("api", g -> { g.get("/", ctx -> ctx.text("apiRoot")); g.get("{id}", ctx -> ctx.text("api-" + ctx.pathParam("id"))); });- Parameters:
path- the common path prefixgroup- the function to register the rout handlers
-
head
Adds a HEAD handler to the route configuration.- Parameters:
path- The path pattern to match the request URI.handler- The handler to invoke when a HEAD request matches the path.roles- roles that are associated with this endpoint.
-
get
Adds a GET handler to the route configuration.- Parameters:
path- The path pattern to match the request URI.handler- The handler to invoke when a GET request matches the path.roles- roles that are associated with this endpoint.
-
post
Adds a POST handler to the route configuration.- Parameters:
path- The path pattern to match the request URI.handler- The handler to invoke when a POST request matches the path.roles- roles that are associated with this endpoint.
-
put
Adds a PUT handler to the route configuration.- Parameters:
path- The path pattern to match the request URI.handler- The handler to invoke when a PUT request matches the path.roles- roles that are associated with this endpoint.
-
patch
Adds a PATCH handler to the route configuration.- Parameters:
path- The path pattern to match the request URI.handler- The handler to invoke when a PATCH request matches the path.roles- roles that are associated with this endpoint.
-
delete
Adds a DELETE handler to the route configuration.- Parameters:
path- The path pattern to match the request URI.handler- The handler to invoke when a DELETE request matches the path.roles- roles that are associated with this endpoint.
-
trace
Adds a TRACE handler to the route configuration.- Parameters:
path- The path pattern to match the request URI.handler- The handler to invoke when a TRACE request matches the path.roles- roles that are associated with this endpoint.
-
options
Adds an OPTIONS handler to the route configuration.- Parameters:
path- The path pattern to match the request URI.handler- The handler to invoke when an OPTIONS request matches the path.roles- roles that are associated with this endpoint.
-
filter
Add a filter for all matched requests. -
before
Add a pre-processing filter for all matched requests. -
after
Add a post-processing filter for all matched requests. -
handlers
List<Routing.Entry> handlers()Return all the registered handlers. -
filters
List<HttpFilter> filters()Return all the registered filters. -
errorHandlers
Map<Class<?>,ExceptionHandler<?>> errorHandlers()Return all the registered Exception Handlers.
-