0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-15 17:21:17 -05:00

Minor changes on http middleware.

This commit is contained in:
Andrey Antukh 2020-12-21 13:39:39 +01:00 committed by Alonso Torres
parent f12ade3b67
commit 84e95ab4c2

View file

@ -26,6 +26,7 @@
(letfn [(parse-transit [body]
(let [reader (t/reader body)]
(t/read! reader)))
(parse-json [body]
(let [reader (io/reader body)]
(json/read reader)))
@ -38,10 +39,12 @@
(catch Exception e
(let [type (if (:debug cfg/config) :json-verbose :json)
data {:type :parse
:hint "Unable to parse request body"
:hint "unable to parse request body"
:message (ex-message e)}]
{:status 400
:headers {"content-type" "application/transit+json"}
:body (t/encode-str data {:type type})}))))]
(fn [{:keys [headers body request-method] :as request}]
(let [ctype (get headers "content-type")]
(handler