Search code examples
clojurecompojureclout

Wildcarding Compojure Routes gives a warning


The following route works as I would like - i.e. match /pref/ and bind * to the rest of the path.

(GET "/pref/*" [*] (do (println *) (resp (str "Hello " *))))

However there's a complaint to stdout:

WARNING: * should not be used as a route binding.

The clout docs suggest that wildcarding with * is fine, the compojure docs don't explain how I should do this idiomatically without provoking the warning, or what the reason for the warning is. I must confess to a certain unease binding * myself although I'm not sure why.


Solution

  • After some poking around, this seems to satisfy, using the inline regexp functionality to match everything. Still not sure what the warning is for.

    (GET "/pref/:path{.*}" [path] (do (println path) (resp (str "Hello " path))))