wrap-multipart-params

ring.middleware.multipart-params

  • (wrap-multipart-params handler & [opts])
Middleware to parse multipart parameters from a request. Adds the
following keys to the request map:
:multipart-params - a map of multipart parameters
:params - a merged map of all types of parameter
Takes an optional configuration map. Recognized keys are:
:encoding - character encoding to use for multipart parsing. If not
specified, uses the request character encoding, or "UTF-8"
if no request character encoding is set.

0 Examples top

Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source ring/middleware/multipart_params.clj:59 top

(defn wrap-multipart-params
  "Middleware to parse multipart parameters from a request. Adds the
  following keys to the request map:
    :multipart-params - a map of multipart parameters
    :params           - a merged map of all types of parameter
  Takes an optional configuration map. Recognized keys are:
    :encoding - character encoding to use for multipart parsing. If not
                specified, uses the request character encoding, or \"UTF-8\"
                if no request character encoding is set."
  [handler & [opts]]
  (fn [request]
    (let [encoding (or (:encoding opts)
                       (:character-encoding request)
                       "UTF-8")
          params   (if (multipart-form? request)
                     (parse-multipart-params request encoding)
                     {})
          request  (merge-with merge request
                     {:multipart-params params}
                     {:params params})]
      (handler request))))
Vars in ring.middleware.multipart-params/wrap-multipart-params: defn fn let
Used in 0 other vars

Comments top

No comments for wrap-multipart-params. Log in to add a comment.