Compojure uses clout to map routes. The dot symbol is of particular importance in driving directions. It is a marker separator, similar to a slash character. The following characters have this value in the meaning: / . , ; ? / . , ; ? .
This means that a route like "/images/:id" will not match the uri of the form /images/name.jpg , since images , name and jpg each represents a separate token in clout.
To match this, you can make your route in several ways, depending on your needs.
If all your images have a .jpg extension, the easiest way to do this is to:
(GET "/images/:id.jpg" [id] ...)
If the extension expands, you can do the following:
(GET "/images/:name.:extension" [name extension] ...)
If you want to restrict the extension, you can pass the regular expression to compojure / clout:
(GET ["/images/:name.:ext", :ext #"(jpe?g|png|gif)"] [name ext] ...)
You can also use a wildcard that is less accurate and matches any uri starting with /images/ :
(GET "/images/*" [*] ...)
source share