Frage

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 ?

War es hilfreich?

Lösung

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top