Instances of controllers are created by the URL dispatcher to handle requests from the client.
Methods from a controller may be mapped to an URL in a module either by adding the maps manually into the module or by annotating controller methods and using URLMapping factory macros.
When a URL mapping matches a request, the dispatcher will call the following on the mapped controller, in order : init, beforeRequest, the mapped method and afterRequest.
Throughout the documentation of this interface, the "mapped method" refers to a controller method that has been mapped and succesfully matched to a request by the dispatcher.
Methods
afterRequest (mapping:URLMapping, requestInfo:RequestInfo):Void
This is called after the mapped controller method has been called. Use this method to perform any post-request operations.
This method is only called when beforeRequest returns true and the mapped controller method execution isn't interrupted.
Parameters:
mapping | The mapping that lead to this contoller |
---|---|
requestInfo | The HTTP request information |
beforeRequest (mapping:URLMapping, requestInfo:RequestInfo):Bool
Called before the request dipstacher calls the mapped controller method.
You can use this method to do any pre-request processing. You must indicate if the dispatcher must call the controller method specified in the mapping by returning true or false.
Parameters:
mapping | The mapping that lead to this controller |
---|---|
requestInfo | The HTTP request information |
Returns:
True if the dispatcher must call the controller according to the given request information. False to prevent the dispatcher from calling the controller