HTTP filters

Request filters are invoked when a request is received from an HTTP client, before it is forwarded to the HTTP server.

Response filters are invoked when a response is received from the HTTP server, before it is forwarded to the HTTP client.

Duplex filters are invoked for both requests and responses.

Filters are given the opportunity to look at the request/response and do whatever they want with it: let it through, modify it, or reject it. Unless it's rejected, the packet is then forwarded to its destination.


All filters define the following variables, which can be accessed from the JavaScript code in filters:

  • log : A Logger object to output messages to the logging system

  • context : an object containing various objects. This context is visible to all filters for a given HTTP request. The following objects will always be available in filters, but some filters may also define additional objects.

    • context.request : a request object, available in all filters

    • context.response (only for response filters): a response object

    • context.filterContext : a context that is visible to all invocations of this filter, as long as the Gallium Data instance is up

    • context.threadContext : a context that is attached to the current thread. This is used in some advanced use cases, when using non-thread-safe objects.

    • context.projectContext : a context that is visible by all invocations of all filters in the project. Be careful when storing values in this context, as they never go away and can clog up memory if used excessively.

    • context.result: a result object used to indicate failure, or to override the request/response completely.

Request filter types

Response filter types

Duplex filter types