Fork me on GitHub

hi there! I'm starting a new project, and I've used bidi in the past, but i'm interested in reitit


with bidi, I use it very simply - usually have a tree of routes which return keywords, on the back end these are matched to a large map of type kw->handler-fn, on the front end I use accountant to dispatch events with re-frame


I use it this way because, putting back end specific things like handler functions in the route map means I would have to duplicate my routes for the front end


is there anyone with overlapping front/back-end routes using reitit who can show me how they do it? just replicate routes?


looks good i'll study the options!


the custom expander looks very similar to what I achieved with bidi/my own keyword matching middleware


very cool. thanks for the link!


Your welcome. As this is a quite common case, there could be a new option :reitit.ring/handler-registry in the ring-handler doing this without the expander boilerplate? There is already :reitit.middleware/registry and (and :reitit.interceptor/registry) for expanding keywords into middleware/interceptors.


also, a e2e-example project would be nice.


yes, that's the way bidi does it - a third optional function which gets the result of the match and you're free to dispatch as you like


haven’t used that feature with bidi, but I guess it dispatches to the function at request-time? with reitit, the expansion happens at router creation time.


yes, at request time


it's simple but i guess it has its downsides


the expander example can emit whole endpoints, with route data, methods etc. we want to validate those and fail fast if there is a error. and the perf is much better when the route tree is compiled forehand.


(trying to make the route data validation much better, and on by default)


actually, for ring, it should be something like :reitit.ring/name-registry as it’s not about handlers. Hmm.


hmm. i've enjoyed the simplicity of just nesting functions where the data from each is passed down the line.. eg, just match a keyword, the handler has middleware to see if it accepts a get or a post... looks like reitit is much more up-front about a lot of things which I would just kick down the line


still comparing the two to see which would fit my mental model more.. performance aside.


i like having a very bare-bones route map i can refer to, but it looks like the expansion takes care of that


you can do that too. just mount a handler into the path, it accepts all method. you need to route the method etc. yourself then.


yes, i can see that


looks like it won't be too much of a step to drop reitit in and then gradually conform to it haha


thanks again!

👍 4