我正在使用Peridot - https://github.com/xeqi/peridot 测试我的应用程序,一切正常,直到我尝试使用JSON数据模拟POST请求:
(require '[cheshire.core :as json]) (use 'compojure.core)
(defn json-post [req] (if (:body req) (json/parse-string (slurp (:body req)))))
(defroutes all-routes (POST "/test/json" req (json-response (json-post req))))
(def app (compojure.handler/site all-routes))
(use 'peridot.core)
(-> (session app) (request "/test/json" :request-method :post :body (java.io.ByteArrayInputStream. (.getBytes "hello" "UTF-8")))
会导致IOException: stream closed
。
有更好的方式吗?