Plugin request callbacks

In general, you just need to use the respond() function to create request handlers. However, if you’re implementing features which affect all your request handlers, such as authentication systems, you may find these callbacks useful.

Interface (for overriding)

Define your own implementations of these functions by including them in the methods for O.plugin(), or add functions after the object has been created.

function requestBeforeHandle(E)

Called before a request is handled. E is an Exchange object.

To abort the request handling, either return false to generate a 403 Forbidden response, or generate a response in the callback. Just as in the request handler itself, you can use E.render() or the body and kind properties of E.response.

If a response is generated and false is returned, the generated response will be used.

This callback is useful for enforcing permissions, for example, checking that the current user is a member of a particular group.

function requestBeforeRender(E, view, templateName)

Called before a template is rendered using E.render() in a request handler. E is an Exchange object, view is the view about to be rendered, and templateName is the name of the template which will be used.

This callback function may modify the view object.

function requestAfterHandle(E)

Called after a request is handled. E is an Exchange object. The response can be modified by this callback.