Package dev.relism.flash.extension
Class FlashRegistrar<SELF extends FlashRegistrar<SELF>>
java.lang.Object
dev.relism.flash.extension.FlashRegistrar<SELF>
- Type Parameters:
SELF- concrete registrar type — enables fluent chaining without casting
- Direct Known Subclasses:
FlashApp,FlashScope
Common route-registration surface shared by
FlashApp and FlashScope.
All route methods register immediately — no deferred .with() call.
Middleware is passed as a varargs third argument:
app.get("/ping", (req, res) -> "pong")
app.get("/secured", (req, res) -> user(), oidc.protect())
app.get("/admin", handler, oidc.requireRole("admin"), rateLimiter)
Extensions receive a FlashApp during their single configure declaration.
Extension installation (install()) is only available on
FlashApp — scoped install is intentionally unsupported.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidRegisters a middleware in this registrar's own scope (global or scope-level).protected abstract voidaddRoute(HttpMethod method, String path, RequestHandler handler, List<MiddlewareNode> mw) Adds a route immediately to this registrar's deferred compilation list.protected abstract voidaddWsRoute(String path, WebSocketEndpoint endpoint) final SELFany(String path, SimpleHandler.FunctionalHandler h, Middleware... mw) Registershunder everyHttpMethod: for handlers indifferent to verb (e.g. a proxy).final SELFconnect(String path, SimpleHandler.FunctionalHandler h, Middleware... mw) final SELFconnectWith(String path, SimpleHandler.FunctionalHandler h, MiddlewareNode... mw) abstract FlashContextctx()Returns theFlashContextfor this registrar.final SELFdelete(String path, SimpleHandler.FunctionalHandler h, Middleware... mw) final SELFdeleteWith(String path, SimpleHandler.FunctionalHandler h, MiddlewareNode... mw) final SELFget(String path, SimpleHandler.FunctionalHandler h, Middleware... mw) final SELFgetWith(String path, SimpleHandler.FunctionalHandler h, MiddlewareNode... mw) final SELFhead(String path, SimpleHandler.FunctionalHandler h, Middleware... mw) final SELFheadWith(String path, SimpleHandler.FunctionalHandler h, MiddlewareNode... mw) protected static RequestHandlerinstantiate(Class<?> cls) protected static WebSocketEndpointinstantiateWs(Class<?> cls) final SELFoptions(String path, SimpleHandler.FunctionalHandler h, Middleware... mw) final SELFoptionsWith(String path, SimpleHandler.FunctionalHandler h, MiddlewareNode... mw) final SELFpatch(String path, SimpleHandler.FunctionalHandler h, Middleware... mw) final SELFpatchWith(String path, SimpleHandler.FunctionalHandler h, MiddlewareNode... mw) final SELFpost(String path, SimpleHandler.FunctionalHandler h, Middleware... mw) final SELFpostWith(String path, SimpleHandler.FunctionalHandler h, MiddlewareNode... mw) final SELFpurge(String path, SimpleHandler.FunctionalHandler h, Middleware... mw) final SELFpurgeWith(String path, SimpleHandler.FunctionalHandler h, MiddlewareNode... mw) final SELFput(String path, SimpleHandler.FunctionalHandler h, Middleware... mw) final SELFputWith(String path, SimpleHandler.FunctionalHandler h, MiddlewareNode... mw) final SELFquery(String path, SimpleHandler.FunctionalHandler h, Middleware... mw) final SELFqueryWith(String path, SimpleHandler.FunctionalHandler h, MiddlewareNode... mw) final SELFScanspackageNameforRequestHandlersubclasses with a routing annotation (@Routeor@GET,@POST, …).final SELFtrace(String path, SimpleHandler.FunctionalHandler h, Middleware... mw) final SELFtraceWith(String path, SimpleHandler.FunctionalHandler h, MiddlewareNode... mw) final SELFuse(Middleware... middlewares) Adds middlewares to this registrar's own scope.final SELFuse(MiddlewareNode... middlewares) Adds named middleware nodes whose ordering constraints are compiled at boot.
-
Constructor Details
-
FlashRegistrar
public FlashRegistrar()
-
-
Method Details
-
get
-
post
-
put
-
delete
-
patch
-
options
-
head
-
trace
-
connect
-
purge
-
query
-
any
Registershunder everyHttpMethod: for handlers indifferent to verb (e.g. a proxy). -
getWith
-
postWith
-
putWith
-
deleteWith
-
patchWith
-
optionsWith
-
headWith
-
traceWith
-
connectWith
-
purgeWith
-
queryWith
-
use
Adds middlewares to this registrar's own scope. OnFlashApp: applied to every route on the app. OnFlashScope: applied to every route in this scope only. Order-independent: middleware is resolved atFlashApp.start(). -
use
Adds named middleware nodes whose ordering constraints are compiled at boot. -
scan
ScanspackageNameforRequestHandlersubclasses with a routing annotation (@Routeor@GET,@POST, …). Each match is constructed with its public no-arg constructor and registered immediately.- Throws:
InitializationException- if the package is empty, not found, or any handler class fails to load or instantiate
-
ctx
Returns theFlashContextfor this registrar. -
addRoute
protected abstract void addRoute(HttpMethod method, String path, RequestHandler handler, List<MiddlewareNode> mw) Adds a route immediately to this registrar's deferred compilation list. Subclasses may prepend a namespace prefix and inject scope middlewares before storing. -
addWsRoute
-
addMiddleware
Registers a middleware in this registrar's own scope (global or scope-level). -
instantiate
-
instantiateWs
-