Fork me on GitHub
#reitit
<
2018-10-03
>
minikomi04:10:43

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

minikomi04:10:45

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

minikomi04:10:25

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

minikomi04:10:33

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

minikomi05:10:36

looks good i'll study the options!

minikomi05:10:20

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

minikomi05:10:26

very cool. thanks for the link!

ikitommi05:10:14

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.

ikitommi05:10:29

also, a e2e-example project would be nice.

minikomi05:10:06

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

ikitommi05:10:09

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.

minikomi05:10:31

yes, at request time

minikomi05:10:47

it's simple but i guess it has its downsides

ikitommi05:10:45

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.

ikitommi05:10:11

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

ikitommi05:10:47

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

minikomi05:10:00

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

minikomi05:10:01

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

minikomi05:10:41

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

ikitommi05:10:42

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.

minikomi05:10:07

yes, i can see that

minikomi05:10:36

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

minikomi05:10:23

thanks again!

👍 4