Module io.avaje.jex
Package io.avaje.jex

Interface Routing


public sealed 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.
    • withRoles

      Routing withRoles(Set<Role> permittedRoles)
      Specify permittedRoles for the last added handler.
      
       routing
       .get("/customers", getHandler).withRoles(readRoles)
       .post("/customers", postHandler).withRoles(writeRoles)
       ...
      
       
      Parameters:
      permittedRoles - The permitted roles required for the last handler
    • withRoles

      Routing withRoles(Role... permittedRoles)
      Specify permittedRoles for the last added handler using varargs.
      
       routing
       .get("/customers", getHandler).withRoles(ADMIN, USER)
       .post("/customers", postHandler).withRoles(ADMIN)
       ...
      
       
      Parameters:
      permittedRoles - The permitted roles required for the last handler
    • error

      <T extends Exception> Routing error(Class<T> exceptionClass, ExceptionHandler<T> handler)
      Registers an error 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
      Returns:
      updated routing
    • path

      Routing path(String path, Routing.Group group)
      Add a group of route handlers with a common path prefix.
    • head

      Routing head(String path, ExchangeHandler handler)
      Add a HEAD handler.
    • get

      Routing get(String path, ExchangeHandler handler)
      Add a GET handler.
    • post

      Routing post(String path, ExchangeHandler handler)
      Add a POST handler.
    • put

      Routing put(String path, ExchangeHandler handler)
      Add a PUT handler.
    • patch

      Routing patch(String path, ExchangeHandler handler)
      Add a PATCH handler.
    • delete

      Routing delete(String path, ExchangeHandler handler)
      Add a DELETE handler.
    • trace

      Routing trace(String path, ExchangeHandler handler)
      Add a TRACE handler.
    • options

      Routing options(String path, ExchangeHandler handler)
      Add an OPTIONS handler.
    • filter

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

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

      default Routing after(Consumer<Context> handler)
      Add a post-processing filter for all 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.