This namespace creates interceptors for ring-core middlewares.

Ring provides a trove of useful and familiar functionality; this namespace exposes that functionality as interceptors that work with Pedestal.

In some cases, some or all of the Ring middleware has been reimplemented here.


(content-type & [opts])

Applies a Content-Type header to a response if missing by mapping the file name extension in the request’s URI.

The MIME mapping occurs in the function ring.util.mime-type/ext-mime-type.

The opts arguments are key/value pairs; the :mime-types key is a map of overrides for extensions to MIME type mappings.


Add support for HTTP cookies. On :enter, a :cookies key is added to the request map, containing the parsed cookie data (from the “cookie” HTTP header), as a map from cookie name to cookie data; each cookie is itself a map with key :value.

This is a wrapper around the ring.middleware.cookies namespace.

When the response map contains a :cookies key, a “Set-Cookie” header will be added to propagate cookie data back to the client.


(fast-resource root-path)(fast-resource root-path opts)

Fast access to static resources from the classpath; essentially works like the resource interceptor, but the response :body will be a java.nio.channels.FileChannel that can be streamed to the client asynchronously.

A file is large if it is larger than the HTTP buffer size, which is calculated via io.pedestal.http.request/response-buffer-size and defaults to 1460 bytes.

If succesful, marks the current tracing span as routed, with a route-name of :fast-resource.

If your container doesn’t recognize FileChannel response bodies, this interceptor will cause errors.

Supports a map of options:

:index? - If path is a directory, will attempt to find an ‘index.*’ file to serve. Defaults to true :follow-symlinks? - Serve files through symbolic links. Defaults to false :loader - A class loader specific for these resource fetches. Default to nil (use the main class loader).


(file root-path & [opts])

Allow file-system files to be accessed as static resources. On :enter, if a static file can be found that matches incoming request URI, a response is generated from its content. Since the file interceptor usually ordered before any routing interceptor, this means that such files can mask other application routes.

The interceptor supports both GET and HEAD requests.

The underlying support comes from ring.middleware.file/file-request.

The :body key of the response will be a

If succesful, marks the current tracing span as routed, with a route-name of :file.

Options are specified as key/value pairs after the root-path.

Common options are :index-files? (defaults to true) which maps directory requests to requests for an index file (if present), and :allow-symlinks? (defaults to false) which allows symbolic links to be followed rather than ignored.


(file-info & [mime-types])

An interceptor that, on :leave, will check the request’s “if-modified-since” headed and convert the response into a status 304 if the underlying file (the :body of the response, a has not been modified since the specified date. It will also set the “Content-Type” response header. The :mime-types option can be provided, it works the same here as in the content-type interceptor.

See ring.middleware.file-info/file-info-response for more details.



Support temporary data (the “flash”) in the session (see session).

On :leave, the :flash key of the response is stored into the session.

On :enter, the previously stored flash value, if any, is removed from the session and added as the request :flash key.



Interceptor to handle head requests

On :enter, when the request method is :head, the request method is converted to :get. On :leave, for a :head request, the response :body is set to nil.


Retained for backward compatibility. io.pedestal.http.params/keyword-params is recommended


(multipart-params & [opts])

Interceptor for multipart form parameters (i.e., forms with file uploads).

A wrapper around ring.middleware.multipart-params/multipart-params-request.

This will add a :multipart-params key to the request, and merge the multipart parameters into the request :params map.


(nested-params & [opts])

Interceptor for ring.middleware.nested-params/nested-params-request Ring middleware.

Nested parameter names follow a particular naming pattern, the result is that the :params may of the request is converted to a nested map.



Adds support for the “if-modified-since” and “if-none-match” request headers; generally this applies to responses generated via the file or resource interceptors.

This is a wrapper around ring.middleware.not-modified/not-modified-response.


(params & [opts])

Extract query parameters from the request URI and request body and adds a :query-params and :form-params keys to the request, and merges those maps into the request :params map.

This is a wrapper around ring.middleware.params/params-request.


(resource root-path)

Allows access to static resources on the classpath.

This is a wrapper around ring.middleware.resource/resource-request.

If succesful, marks the current tracing span as routed, with a route-name of :resource

The response :body may be a or a depending on the request and the classpath.


deprecated in 0.7.0

(response-fn-adapter response-fn)(response-fn-adapter response-fn opts)

Adapts a Ring middleware fn taking a response and request (that returns a possibly updated response), into an interceptor-compatible function taking a context map, that can be used as the :leave callback of an interceptor.

The response-fn is only invoked if there is a non-nil :response map in the context.

If an opts map is provided (the arity two version) and is not empty, then the response function must be arity three, taking a response map, request map, and the provided options.


(session)(session options)

Interceptor for session ring middleware. A session is a simple store of data, associated with a single client, that persists between requests. A cookie (by default “ring-session”) is used to connect requests and responses to a session. A store (the default is an in-memory Atom) stores the data between requests.

The request key :session is a map storing the session data, and :session/key store the key uniquely identifying the client session.

Options are documented in ring.middleware.session/wrap-session.

On :enter, uses ring.middleware.session/session-request, which adds a :session key to the request.

On :leave, uses the :session and :session/key response keys to update the store and, if necessary, create a new cookie with the new session key.

It is the application’s responsibility to copy the :session and :session/key to the response. When this does not occur, the session will be removed from the store.