2
나는 clojure에서 링을 사용하여 매우 간단한 API를 만들려고합니다. 난 rack.middleware.format-params 미들웨어를 사용하여 출력을 json으로 변환하고, json의 입력을 데이터 구조를 클로저로 변환한다.링 형식 매개 변수 미들웨어로 게시 된 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