I'm trying to access the parameter foo, using compojure, in a request like this:
/api/xyz?foo=bar
The compojure destructuring syntax looks good, so I would like to use it. However the following just serves me the "Page not found":
(defroutes app-routes
(GET "/api/xyz/:foo" [foo] (str "foo: " foo))
(route/not-found "Page not found"))
Which is kind of weird, since the verbose destructuring below works and gives me "foo: bar":
(defroutes app-routes
(GET "/api/xyz" {{foo :foo} :params} (str "foo: " foo))
(route/not-found "Page not found"))
What am I missing?
If foo
is always passed as a URL parameter, you want your code to be like this:
(defroutes app-routes
(GET "/api/xyz" [foo] (str "foo: " foo))
(route/not-found "Page not found"))