Compojure get request when route is associated
I use to define routes in this mode:
(GET "/home" [req] (home-page req))
and then I have the entire request object available for use inside my handler.
but now I want to use anchor routes like:
(GET "/details/:id" [id] (details-page id))
in this case, it seems that I cannot get the AND query and associated arguments at the same time. I tried:
(GET "/details/:id" [id req] (details-page id req))
but req comes up to zero.
is there a way to get a request for anchor routes?
I need bindings so I don't need to do things like:
(GET "/details" [req] (details-page req))
, and then <a href="/details?id=123">...
and I need a request to access the session and request headers.
any suggestion?
early.
source to share
According to https://github.com/weavejester/compojure/wiki/Destructuring-Syntax you should bind req
to the whole request by adding :as req
bindings to the vector:
(GET "/details/:id" [id :as req] (details-page id req))
source to share