 (ns cljsbin.middleware
   (:require
+   [clojure.string]
    [macchiato.middleware.defaults :as defaults]
    [macchiato.util.request :as util]
    [cljs.nodejs :as node]))

    (.startsWith type "application/json")))

;; TODO error should be 400 if payload is badly formatted
(defn wrap-json-body
  "If the request has json content-type, attempt to parse the body and
  set it in the :json property of the request."

      (concat-body
       (:body request)
       (fn [body]
         (let [json-body (parse-json body raise)]
           (-> request
               (assoc :json json-body)
               (assoc :body body) ;; not sure why this is needed, should be set by the other mw
