I'm working through the tutorial Mark McGranaghan REST Tutorial however I'm trying to do it using Noir instead.
I can add new items, however it never takes the body of the PUT command.
I think the problem with how I'm trying to construct the put statement. I'm thinking the {:keys [id attrs]} is the issue, because I'm trying to tell it the json content is in the url, when its not, its in the body. Can anyone advise how i retrieve it from the body using noirs defpage?
(put is in a separate elem file)
(defn put [id attrs]
(let [new-attrs (merge (get id) attrs)]
(swap! elems assoc id new-attrs)
new-attrs))
(defpage [:put "/elems/:id"] {:keys [id attrs]}
(json-response (elem/put id attrs)))
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
But you just need to add that "backbone" (I personally renamed it to "json-params") middleware first.