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)))
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.