-
Notifications
You must be signed in to change notification settings - Fork 90
Closed
Description
I have some code:
(defresource foo [id]
:available-media-types ["application/json"]
:allowed-methods [:get]
:handle-ok
(fn [ctx]
{:hello id}))
(def routes ["/foo/" {[:id] foo}])
(def app (-> (make-handler routes) (wrap-default api-default)))
This doesn't work as-is because something is trying to cast the foo
function to an associative structure, so this seemed like it might work:
(def routes ["/foo/" {[:id] (fn [req] (foo (get-in req [:route-params :id])}])
But (foo x)
produces a handler function that closes over x
, it seems since once again something was trying to cast a function to an associative structure.
What I ended up with was:
(def routes ["/foo/" {[:id] (fn [req] ((foo (get-in req [:route-params :id]) req)}])
Which is kind of messy, especially when compared to something like Compojure:
(defroutes routes (ANY "/foo/:id" [id] (foo id)))
Am I missing something?
Metadata
Metadata
Assignees
Labels
No labels