Clojure Noir Json Put Clojure Noir Json Put json json

Clojure Noir Json Put


If you are passing "attrs=somevalue" in the post then that will work, but if you are trying to capture all the key-value pairs, this works for me in 1.3.0-beta1:

(defpage [:put "/elems/:id"] attrs   (response/json {:attrs attrs}))

then:

$ curl -H "Accept: application/json" -X PUT -d "foo=bar" http://localhost:8080/elems/123=> {"attrs":{"id":"123","foo":"bar"}}


Use Chris Granger's JSON-parsing middleware function from here, and use it as described here to receive JSON data.

in your case it'll look like

(defpage [:put "/elems/:id"] {{:keys [attr1 attr2 attr3]} :backbone }         "OK")

But you just need to add that "backbone" (I personally renamed it to "json-params") middleware first.


So these are form parameters? If so, destructuring params like you did here should work just fine. You can get the whole request inside the defpage using noir.request. I'd take at look at that and see what it contains. It should clarify things significantly.