Created
September 15, 2012 19:20
-
-
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"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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