Package com.robothy.netty.router
Class AbstractRouter
java.lang.Object
com.robothy.netty.router.AbstractRouter
- All Implemented Interfaces:
Router
- Direct Known Subclasses:
SpringWebRouter
public abstract class AbstractRouter extends java.lang.Object implements Router
-
Field Summary
Fields inherited from interface com.robothy.netty.router.Router
DEFAULT_NOT_FOUND_HANDLER -
Constructor Summary
Constructors Constructor Description AbstractRouter() -
Method Summary
Modifier and Type Method Description <T extends java.lang.Throwable>
RouterexceptionHandler(java.lang.Class<T> exceptionType, ExceptionHandler<T> handler)Set a handler for exceptions withexceptionType.ExceptionHandler<java.lang.Throwable>findExceptionHandler(java.lang.Class<? extends java.lang.Throwable> exceptionType)Find the best match exception handler for the givenexceptionType.RouternotFound(HttpRequestHandler handler)Set resource not found handler.protected HttpRequestHandlernotFoundHandler()RouterstaticResource(java.lang.String rootPath)The router will map the request uri to the relative path of files under therootPathdirectory.protected com.robothy.netty.router.StaticResourceMatcherstaticResourceMatcher()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
AbstractRouter
public AbstractRouter()
-
-
Method Details
-
notFound
Description copied from interface:RouterSet resource not found handler. -
staticResource
Description copied from interface:RouterThe router will map the request uri to the relative path of files under therootPathdirectory. By default, the router loads static resources from `classpath:static`.- The
rootPathmust be a valid directory, the router will map the request uri to relative path of files under therootPathdirectory. - If static resource paths conflict with routes registered via
route(), the router will ignore static resources.
- Specified by:
staticResourcein interfaceRouter- Parameters:
rootPath- static resources root directory or resource path.- Returns:
- this.
- The
-
notFoundHandler
-
staticResourceMatcher
protected com.robothy.netty.router.StaticResourceMatcher staticResourceMatcher() -
exceptionHandler
public <T extends java.lang.Throwable> Router exceptionHandler(java.lang.Class<T> exceptionType, ExceptionHandler<T> handler)Description copied from interface:RouterSet a handler for exceptions withexceptionType.- Specified by:
exceptionHandlerin interfaceRouter- Type Parameters:
T- type of the exception to handle..- Parameters:
exceptionType- subtype of Throwable.handler- handle specific exception.- Returns:
- this.
-
findExceptionHandler
public ExceptionHandler<java.lang.Throwable> findExceptionHandler(java.lang.Class<? extends java.lang.Throwable> exceptionType)Description copied from interface:RouterFind the best match exception handler for the givenexceptionType.- Specified by:
findExceptionHandlerin interfaceRouter
-