@steven427 nice solution I like it 🙂
If I want to generate a bunch of (very repetitive) routes in reitit, am I stuck with writing a macro? The function I’ve written complains when I compile my namespace which declares my routes:
:cause "No implementation of method: :expand of protocol: #'reitit.core/Expand found for class: clojure.lang.Symbol"
I think this error would happen if you're trying to pass a symbol as the first thing after a route declaration
Not sure exactly what you're trying to do, but the answer is probably "no" you don't need a macro :)
Just create all your routes as data, building them up into one big vector of routes and sticking that into whatever router you want
After hitting a wall with this yesterday I finally came back in the evening and took a stab at a macro; it worked. I’m generating a lot of the kw/fn names, so it might be more delayed evaluation than it’s worth trying to do in a function. The only consumer of this macro will be the call to reitit.ring/routes
, so it doesn’t feel too bad and the macro itself is simple enough that I (probably?) won’t shoot myself in the foot. 🙂
https://github.com/pariyatti/kosa/blob/f24abee963eeaf600acb74dade35fa6acddaefc3/src/cages/dispatch.clj#L9
https://github.com/pariyatti/kosa/blob/f24abee963eeaf600acb74dade35fa6acddaefc3/src/kosa_crux/routes.clj#L49