Package com.robothy.netty.router
Class AbstractRouter
java.lang.Object
com.robothy.netty.router.AbstractRouter
- All Implemented Interfaces:
Router
- Direct Known Subclasses:
SpringWebRouter
-
Field Summary
Fields inherited from interface com.robothy.netty.router.Router
DEFAULT_NOT_FOUND_HANDLER -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionexceptionHandler(Class<T> exceptionType, ExceptionHandler<T> handler) Set a handler for exceptions withexceptionType.findExceptionHandler(Class<? extends Throwable> exceptionType) Find the best match exception handler for the givenexceptionType.notFound(HttpRequestHandler handler) Set resource not found handler.protected HttpRequestHandlerstaticResource(String rootPath) The router will map the request uri to the relative path of files under therootPathdirectory.protected com.robothy.netty.router.StaticResourceMatcher
-
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 Throwable> Router exceptionHandler(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
Description copied from interface:RouterFind the best match exception handler for the givenexceptionType.- Specified by:
findExceptionHandlerin interfaceRouter
-