Requests
HTTP requests are represented as Clojure maps, and adhere to the Ring specification. This means they have a set of standard keys that any Ring-based application can use.
Request maps can be extended with custom keys. Compojure adds a number of additional keys through middleware functions.
Standard Ring keys
:server-port
- The port on which the request is being handled.
:server-name
- The resolved server name, or the server IP address.
:remote-addr
- The resolved server name, or the server IP address.
:uri
- The request URI string. Always starts with "/".
:query-string
- The query string, if present.
:scheme
- The transport protocol. Either
:http
or:https
:request-method
- The HTTP request method. One of
:get
,:head
,:options
,:put
,:post
or:delete
:content-type
- The MIME type of the request body, if known.
:content-length
- The number of bytes in the request body, if known.
:character-encoding
- The name of the character encoding used in the request body, if known.
:headers
- A Clojure map of lowercase header name strings to corresponding header value strings.
:body
- An InputSteam for the request body, if present.
Standard Compojure keys
:query-params
- A Clojure map of keyword/string pairs that correspond to url-encoded parameters parsed from the query-string.
:form-params
- A Clojure map of keyword/string pairs that correspond to url-encoded parameters parsed from request body.
:route-params
- Parameters matched from parsing the path of a route. If the path is a formatted string, the parameters are encoded as a keyword/string map. If the path is a regular expression, the paramaters are encoded as a vector of matches.
:params
- A merged map of
:query-params
,:form-params
and:route-params
. :cookies
- A Clojure map of keyword/string pairs that correspond to the HTTP cookies stored for this URI.
Optional Compojure keys
:multipart-params
- A Clojure map of keyword/string pairs from multipart-encoded parameters.
Added by the
with-multipart
middleware. Also adds these parameters to the:params
key. :session
- A Clojure map of session data. Added by the
with-session
middleware. :flash
- A Clojure map of flash data. Added by the
with-session
middleware.