Pedestal

Context Map

Description

The context map is passed to each interceptor’s :enter and :leave functions.

There are the keys that interceptor chain execution puts into the context map. Any key not described here is officially undefined and should be regarded as an implementation detail subject to change.

Key Type Description

:bindings

map of var → value

As accepted by clojure.core/with-bindings. Prior to delegating execution to any interceptor, the interceptor framework will ensure that the bindings specified in this map are installed using clojure.core/with-bindings. If this map is altered and included in the returned context from an interceptor, the new bindings in the map will be installed as thread local bindings prior to another interceptor’s execution.

:io.pedestal.interceptor.chain/error

Exception

When error processing is invoked, this value is the most recent exception that triggered error handling.

:io.pedestal.interceptor.chain/execution-id

Opaque

This identifier is set uniquely when the pipeline is invoked. It is useful for correlating log files. Do not assume anything about the structure or type of this identifier.

:io.pedestal.interceptor.chain/queue

Stack of interceptors

These are the interceptors left to execute. You can inspect this for debugging purposes, but to manipulate it you should call enqueue, terminate, or terminate-when.

:io.pedestal.interceptor.chain/terminators

Collection of predicates

After executing each :enter function, Pedestal checks every predicate in this collection, passing the context map to each one. If any of them returns true-ish, Pedestal begins executing the :leave stack.

As Applied to HTTP

A chain of interceptors can be used for any kind of pipelined processing with branching decisions. It is not limited to HTTP request handling.

When used with Pedestal’s HTTP handling, there are additional keys of interest. The context map is created before the first interceptor is invoked. It describes the context of the interceptor execution itself. When the execution chain is connected to an HTTP server, the :request and :response keys have a special purpose.

Pedestal does not attach metadata to the request map.

When processing, take care to modify the map, rather than constructing a new one. Interceptors may add arbitrary keys to the request map, so it is important to preserve keys that your interceptor does not specifically modify.

Key Type Deescription

:request

Request map

See Request Map

:response

Response map

Only present if an interceptor has attached this. See Response Map

Servlet Keys

The following keys are only present when using the Servlet Interceptor.

Key Type Description

:servlet-request

HttpServletRequest

The request that was sent by the client. You should use the Request Map rather than directly accessing this.

:servlet-response

HttpServletResponse

The response object in which the HTTP server wants its response. You should use the Response Map rather than directly accessing this.

:servlet-config

javax.servlet.ServletConfig

The servlet configuration object.

:servlet

javax.servlet.Servlet

The servlet itself.