weavejester / compojure

A concise routing library for Ring/Clojure
Eclipse Public License 1.0
4.08k stars 259 forks source link

URL parameter capture #216

Closed challmand closed 1 year ago

challmand commented 1 year ago

Defining a route as such

(defroutes app-routes
  (GET "/user/:id" [id greeting]
    (str "<h1>" greeting " user " id "</h1>")))

Requesting this route does not capture the greeting param.

curl http://localhost:3000/user/1?greeting=hello
<h1> user 1</h1>

Is there a part I am missing to capture params passed into a route url?

weavejester commented 1 year ago

Have you added the ring.middleware.params/wrap-params middleware?

challmand commented 1 year ago

Thank you for the quick reply. That was the issue. It works now as expected. I was following the Docs here and missed any reference to use wrap-params https://github.com/weavejester/compojure/wiki/Destructuring-Syntax#compojure-specific-destructuring