Fork me on GitHub
#reitit
<
2021-07-06
>
Yehonathan Sharvit18:07:15

I like the idea of having the routing table defined in a EDN file as mentioned here https://cljdoc.org/d/metosin/reitit/0.5.13/doc/ring/middleware-registry However, it seems that we would need a way to decouple between the routing and the functions that define the behaviour of the handler. Is it possible with ring-router?

juhoteperi19:07:34

I think currently not, ring-handler doesn't take option to modify the match before taking the :handler from the match. But I think you can go through the route tree yourself before giving routes to ring-handler.

ikitommi19:07:26

yeah. The current expand takes the whole endpoint. There could be separate expand for handlers?

juhoteperi19:07:41

aha, compile-result takes expand option, but where is that passed in? From router. ring-router docstring doesn't mention it directly, but says to look at ring.core/router : https://github.com/metosin/reitit/blob/master/modules/reitit-core/src/reitit/core.cljc#L357

juhoteperi19:07:52

That should be usable, but you need to go through over http methods yourself

ikitommi20:07:25

I think expand is called for each method. So no need for.http-stuff, but everything under one method. See https://github.com/metosin/reitit/blob/master/modules/reitit-ring/src/reitit/ring.cljc#L25-L30

ikitommi20:07:43

... would be easy to add another expander just for handler, but not sure if that's useful enough.