Created
October 11, 2012 20:56
Revisions
-
jjcomer created this gist
Oct 11, 2012 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ (defn- json-request? [req] (if-let [#^String type (:content-type req)] (not (empty? (re-find #"^application/(vnd.+)?json" type))))) (defn wrap-json-params [handler] (fn [req] (if-let [body (and (json-request? req) (:body req))] (let [bstr (slurp body) json-params (parse-string bstr) req* (assoc req :json-params json-params :params (merge (:params req) json-params))] (handler req*)) (handler req))))