Fork me on GitHub
#reitit
<
2021-09-23
>
Yehonathan Sharvit11:09:13

Is it possible to write a reitit middleware that adds a route?

Yehonathan Sharvit11:09:41

From what I tried, it seems than when a request doesn't match any route, the middlewares are not executed

ikitommi11:09:32

@viebel reitit uses a route-first design - routing is done first, and only after that, the per-endpoint middleware/interceptor chain is executed. You can add mws on top of the router to effect all routes

ikitommi11:09:52

and, yes, you can add routes in mw. But, you also need to re-create the router after that. or have a custom routing happen in a mw.

ikitommi11:09:14

you can also nest routers to make it work similar to compojure, if that’s the thing: https://cljdoc.org/d/metosin/reitit/0.5.15/doc/advanced/composing-routers