All .js
files in extensions/
are loaded and used as Extensions.
An Extension is simply a standard Node.js module that exports an ExtensionFunc.
A function with the following properties:
Optional. If specified, sets the object under config.extensions
that will get passed to this ExtensionFunc when called.
Config is `config.extensions.${configNamespace}`
if configNamespace
is defined, or undefined otherwise. The return value is appended to an internal array of Handlers, looped through on each request.
early
, normal
, or late
. When a request is received, it will go through each Handler in the order early
> normal
> late
, with order within each priority being undefined. Files are loaded after early
if a handler in early
did not already respond.
Exactly one of these must be defined. This Handler is used if either Handler.matchErr
matches what was set for the request, with 9
being a wildcard digit, or Handler.matchPath
matches the request path as a glob expression, with /
being prepended if not already there.
resp
is the current Response. If it returns a string, the response's body is replaced with it.
The error code of the response sent. Defaults to 200 on a new instance.
The response sent to the client.
After calling this, once you return all data on this object is erased, and the request is reinterpreted as being for path
. If path
is undefined, only matchErr
is used in the handlers ran.
Headers sent in the response.
The matching Request for this Response.
The path this request was sent to.
Headers sent in the request.