Class AbstractRouter

java.lang.Object
com.robothy.netty.router.AbstractRouter
All Implemented Interfaces:
Router
Direct Known Subclasses:
SpringWebRouter

public abstract class AbstractRouter extends Object implements Router
  • Constructor Details

    • AbstractRouter

      public AbstractRouter()
  • Method Details

    • notFound

      public Router notFound(HttpRequestHandler handler)
      Description copied from interface: Router
      Set resource not found handler.
      Specified by:
      notFound in interface Router
      Returns:
      this
    • staticResource

      public Router staticResource(String rootPath)
      Description copied from interface: Router
      The router will map the request uri to the relative path of files under the rootPath directory. By default, the router loads static resources from `classpath:static`.
      • The rootPath must be a valid directory, the router will map the request uri to relative path of files under the rootPath directory.
      • If static resource paths conflict with routes registered via route(), the router will ignore static resources.
      Specified by:
      staticResource in interface Router
      Parameters:
      rootPath - static resources root directory or resource path.
      Returns:
      this.
    • notFoundHandler

      protected HttpRequestHandler notFoundHandler()
    • staticResourceMatcher

      protected com.robothy.netty.router.StaticResourceMatcher staticResourceMatcher()
    • exceptionHandler

      public <T extends Throwable> Router exceptionHandler(Class<T> exceptionType, ExceptionHandler<T> handler)
      Description copied from interface: Router
      Set a handler for exceptions with exceptionType.
      Specified by:
      exceptionHandler in interface Router
      Type Parameters:
      T - type of the exception to handle..
      Parameters:
      exceptionType - subtype of Throwable.
      handler - handle specific exception.
      Returns:
      this.
    • findExceptionHandler

      public ExceptionHandler<Throwable> findExceptionHandler(Class<? extends Throwable> exceptionType)
      Description copied from interface: Router
      Find the best match exception handler for the given exceptionType.
      Specified by:
      findExceptionHandler in interface Router