Skip to content

Instantly share code, notes, and snippets.

@larme
Created September 15, 2012 19:20
Show Gist options
  • Save larme/3729378 to your computer and use it in GitHub Desktop.
Save larme/3729378 to your computer and use it in GitHub Desktop.
A modified version of wrap-json for handling content-type like: "application/json; charset=UTF-8"
(defn wrap-json [handler]
(fn [req]
(let [content-type (get-in req [:headers "content-type"])
neue (if (and content-type
(some #{"application/json"}
(string/split content-type #";")))
(update-in req [:params] assoc :json
(json/parse-string (slurp (:body req))
true))
req)]
(handler neue))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment