I have a Clojure service that I'm exposing via REST. I have a page defined as:
(defpage "/package_versions/:id" {:keys [id]}
(do
(println "ID: " id)
(if-let [pv (pv/fetch-one (db/keyspace) id)]
(response/json pv)
(response/status 404 nil))))
What characters are allowed for id? The slugs 1-2-3, 1|2|3, 1_2_3 all work, but 1.2.3 doesn't. Is there a way to make slugs which contain . work? What are the allowed characters in noir routes? Which code is responsible for this behavior: noir, ring, compojure?
Have a look at the Clout test cases.
The slugs used in the tests don't really have special characters in them so I don't know what characters are legal, but at the end of the file there's an example of how to define a custom route matcher that presumably can be used to match dots if you so desire.
I would expect that you can plug the custom route matcher into Noir with either noir.core/compojure-route
or noir.core/custom-handler
.
Also, there are tests with literal dots in them, e.g. "/foo.:ext
that matches URLs like /foo.txt
, so I wouldn't be surprised if it was a feature, not a bug, to not allow dots in slugs.