2
我試圖做一個非常簡單的API在clojure中使用環。我正在使用rack.middleware.format-params中間件將輸出轉換爲json,並將json的輸入轉換爲clojure數據結構。訪問發佈的json與環形格式參數中間件
我得到的輸出很好地工作,但我不能爲我的生活訪問通過json發送的參數。下面是一些代碼,對GET請求的作品,但我不能讓POST請求返回的JSON它臨危
(ns testing.core
(:use [compojure.core]
[ring.middleware.format-params :only [wrap-json-params]]
[ring.middleware.format-response :only [wrap-json-response]]
[ring.adapter.jetty])
(:require [compojure.handler :as handler]))
(defroutes app-routes
(GET "/"
[]
{:body {:hello "world"}})
(POST "/"
{params :params}
{:body params}))
(def app
(-> (handler/api app-routes)
(wrap-json-params)
(wrap-json-response)))
它只是返回這樣的:{}
我在做什麼錯?
而且你還需要Accept頭? – noahlz
你不是個白癡。你是一個救星 – jstuartmilne