Interface Routing


public interface Routing
Routing abstraction.
  • Method Details

    • add

      Add the routes provided by the given HttpService.
    • addAll

      Add all the routes provided by the Routing Services.
    • error

      <T extends Exception> Routing error(Class<T> exceptionClass, ExceptionHandler<T> handler)
      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 handler
      handler - the error handler
    • group

      Routing group(String path, Routing.HttpService 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 prefix
      group - the function to register the rout handlers
    • head

      Routing head(String path, ExchangeHandler handler, Role... roles)
      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

      Routing get(String path, ExchangeHandler handler, Role... roles)
      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

      Routing post(String path, ExchangeHandler handler, Role... roles)
      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

      Routing put(String path, ExchangeHandler handler, Role... roles)
      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

      Routing patch(String path, ExchangeHandler handler, Role... roles)
      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

      Routing delete(String path, ExchangeHandler handler, Role... roles)
      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

      Routing trace(String path, ExchangeHandler handler, Role... roles)
      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

      Routing options(String path, ExchangeHandler handler, Role... roles)
      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

      Routing filter(HttpFilter handler)
      Add a filter for all matched requests.
    • filter

      default Routing filter(Filter handler)
      Add a filter for all matched requests.
    • before

      default Routing before(Consumer<Context> handler)
      Add a pre-processing filter for all matched requests.
    • after

      default Routing after(Consumer<Context> handler)
      Add a post-processing filter for all matched requests.
    • sse

      default Routing sse(String path, Consumer<SseClient> handler, Role... roles)
      Adds an SSE handler to the route configuration.
      Parameters:
      path - The path pattern to match the request URI.
      handler - The sse handler to invoke when a GET request matches the path.
      roles - An array of roles that are associated with this endpoint.
    • 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.