reitit

https://cljdoc.org/d/metosin/reitit/ https://github.com/metosin/reitit/
oly 2020-12-18T09:12:57.432500Z

@steven427 nice solution I like it 🙂

Steven Deobald 2020-12-18T23:56:58.434Z

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"

Dave Russell 2020-12-19T09:20:11.434100Z

I think this error would happen if you're trying to pass a symbol as the first thing after a route declaration

Dave Russell 2020-12-19T09:20:42.434300Z

Not sure exactly what you're trying to do, but the answer is probably "no" you don't need a macro :)

Dave Russell 2020-12-19T09:22:01.434600Z

Just create all your routes as data, building them up into one big vector of routes and sticking that into whatever router you want

Steven Deobald 2020-12-19T18:07:31.434800Z

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