Question

Suppose I have URLs with the format:

Is it possible to write a single handler that matches an arbitrary number of URI parts after http://example.com/node ?

Was it helpful?

Solution

Yes, you can use a wildcard * on the routes:

(GET "/node/*" request (handle request))

You can also define a regular expression over the variable part:

 (GET ["/node/:params", :params #"[^.]+.fn"] [params :as request] (handle params))

That sample will accept all /node/something.fn urls.

Compojure uses clout for the matching part you can read there more alternatives.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top