Arbitrary Number Of parameters With Compojure
I wanted to create an API in CLokure/Compojure that accepted an arbitrary number or parameters. I’m using Luminus framework, and I have generated an app using the +service
template, which creates a RESTful API (see here for details).
The API uses compojure-api which is based on compojure which uses clout as routing syntax.
Compojure supports regular expression to define parameters, so it’s quite straightforward to use them in compojure-api:
(GET "/foo/first/:first/:others{.*}" []
:return s/Any
:path-params [first :- s/Any others :- s/Any]
(ok (str "First: " first " Others: " others))
)
That’s it.