public interface RequestHandler extends org.osgl.Osgl.Function<ActionContext,java.lang.Void>, Destroyable
Defines a thread-save function object that can be applied to a ActionContext
context to produce certain output which could be applied to the H.Response
associated with the context
Destroyable.Util
Modifier and Type | Method and Description |
---|---|
CORS.Spec |
corsSpec()
Get CORS specification that specifically applied to this request handler
|
CSRF.Spec |
csrfSpec()
Get CSRF specification that applied to this request handler
|
boolean |
express(ActionContext context)
Indicate the handler logic is fast enough to be put into network layer’s io thread and does not require to dispatch to worker thread.
|
void |
handle(ActionContext context)
Invoke handler upon an action context
|
void |
prepareAuthentication(ActionContext context)
Setting up handler for authentication.
|
boolean |
requireResolveContext()
Returns if the handler require framework to resolve context.
|
boolean |
sessionFree()
Returns if the handler is session free or not.
|
boolean |
supportPartialPath()
Indicate if this request handler support partial path lookup.
|
destroy, isDestroyed, scope
void handle(ActionContext context)
Invoke handler upon an action context
context
- the context databoolean express(ActionContext context)
Indicate the handler logic is fast enough to be put into network layer’s io thread and does not require to dispatch to worker thread.
Note a handler that implements ExpressHandler
should always return true
for this method
context
- the action contexttrue
if this handler support direct io thread processingboolean supportPartialPath()
Indicate if this request handler support partial path lookup. Usually this method should return false
. However for certain request handler like FileGetter
they need to support partial path lookup. Take the example of the following route mapping:
GET /public staticDir: /public
which map url path /public
to a StaticFileGetter
with base dir set to /public
, it needs to support all path starts with “/public”, like “/public/js/jquery.js” etc.true
if the request handler support partial path lookup or false
otherwiseboolean requireResolveContext()
Returns if the handler require framework to resolve context. Usually it needs to resolve the context so that handler can access request params, session/flash etc. However some static handlers doesn’t require framework to do those things, e.g. FileGetter
void prepareAuthentication(ActionContext context)
Setting up handler for authentication. For example, initialize the missing authentication handler, csrf failure handler.
context
- the current action contextboolean sessionFree()
Returns if the handler is session free or not. If a handler is session free then the framework will NOT resolve session
true
if the handler is session freeCORS.Spec corsSpec()
Get CORS specification that specifically applied to this request handler
CSRF.Spec csrfSpec()
Get CSRF specification that applied to this request handler
Copyright © 2014–2017 ActFramework. All rights reserved.