Package dev.relism.flash.routing
Class AbstractRouter
java.lang.Object
dev.relism.flash.routing.AbstractRouter
- Direct Known Subclasses:
FastPathRouterImpl
Base router contract. Owns error handlers and the compile-time middleware
wrapping logic. The only concrete implementation is
FastPathRouterImpl.
All middleware composition happens once at boot time; the hot-path sees
only a plain RequestHandler call with zero allocation overhead.
Default error handlers
- Dev mode (
-Dflash.env=dev): rich HTML pages with full stack traces. - Prod mode (default): generic JSON — no internal detail leaked to clients.
FlashApp.onNotFound(dev.relism.flash.models.SimpleHandler.FunctionalHandler) /
FlashApp.onException(dev.relism.flash.routing.AbstractRouter.ExceptionHandler).
Registration: use FlashApp — the single
public registration API. doRegister(dev.relism.flash.http.HttpMethod, java.lang.String, dev.relism.flash.models.RequestHandler, dev.relism.flash.routing.Middleware[]) is an infrastructure method.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AbstractRouter.ExceptionHandlerprotected SimpleHandler -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract AbstractRouteraddRoute(HttpMethod method, String path, RequestHandler handler) voidcompile()Eagerly validates and compiles this route graph before traffic is accepted.doRegister(HttpMethod method, String path, RequestHandler handler, Middleware[] middlewares) Registers a handler with a pre-built middleware array.Creates a fresh per-connection scratch object forroute(dev.relism.flash.models.Request, java.lang.Object), ornullif this router implementation keeps no reusable per-connection state.voidvoidabstract RequestHandler
-
Field Details
-
notFoundHandler
-
exceptionHandler
-
-
Constructor Details
-
AbstractRouter
public AbstractRouter()
-
-
Method Details
-
compile
public void compile()Eagerly validates and compiles this route graph before traffic is accepted. -
getNotFoundHandler
-
getExceptionHandler
-
onNotFound
-
onException
-
doRegister
public AbstractRouter doRegister(HttpMethod method, String path, RequestHandler handler, Middleware[] middlewares) Registers a handler with a pre-built middleware array. Compiles the middleware chain once at boot — zero overhead on hot-path. -
newScratch
Creates a fresh per-connection scratch object forroute(dev.relism.flash.models.Request, java.lang.Object), ornullif this router implementation keeps no reusable per-connection state. Called once per connection by the connection driver (e.g.Http1Connection), which holds the opaque result and passes it back into everyroute(dev.relism.flash.models.Request, java.lang.Object)call for that connection's whole lifetime — the same "create once per connection, reuse across requests" shape already used there forRequestParser. thread", which under this codebase's one-virtual-thread-per-connection model is "one per connection with no upper bound and no pooling" — exactly the failure modeConnectionScratchalready exists to avoid for every other per-connection buffer. An explicit, caller-owned scratch object achieves the same per-connection reuse without that unbounded-growth risk, and without requiringroutingto depend ontransport'sConnectionScratchtype (this package has no such dependency than extendingConnectionScratchitself, which is what an earlier draft of this fix assumed). -
route
-
addRoute
-