Skip to content

Parameter Middleware

weavejester edited this page Oct 19, 2010 · 5 revisions

URL-Encoded Parameters

The [[ring.middleware.params/wrap-params|http://mmcgrana.github.com/ring/middleware.params-api.html#ring.middleware.params/wrap-params]] middleware function adds support for url-encoded parameters.

It adds following keys are added to the request map:

  • :query-params - A map of url-encoded parameters parsed from the request query string.
  • :form-params - A map of url-encoded parameters parsed from the request body. The body is only parsed if the content type is set to application/x-www-form-urlencoded.
  • :params - A merged map of all parameter types.

The parameter keys are stored as strings.

(ns example.params
  (:use ring.middleware.params
        ring.util.response
        ring.adapter.jetty))

(defn handler [{params :params}]
  (response (str "Hello " (params "name"))))

(run-jetty (wrap-params handler)
           {:port 8080})

Clone this wiki locally