Fork me on GitHub
#reitit
<
2023-09-29
>
danielneal13:09:06

How do you use the update-paths option of the reitit router? Can you use that it to preprocess / expand route data? If you set this value do you need to make sure you keep the default behaviour that calls impl/accumulate?

ikitommi15:09:24

Yes, you can do all sort of preprocessing with it. You should add your own rules to the default rules - if you find them usefull (e.g. use any coercion)

danielneal15:09:23

What is the rule that propagates information from higher levels to lower levels. e.g. if I have a route [“top-level” {:some-key true} [“/next-level” {:more :info}]] at what point does some-key make it into the next-level

danielneal15:09:27

Ideally I’d place a function after this is done, so I can use this info and expand on it.

ikitommi16:09:21

Here's a short description of the full route expansion : there are several hooks available to change things: https://cljdoc.org/d/metosin/reitit/0.7.0-alpha5/doc/basics/router#behind-the-scenes

ikitommi16:09:19

I think :compile is the one you are looking for. If you use ring, you should compose your code with the reitit-ring default compile. See source code for more info. And please share how and what you did

danielneal09:10:40

Yes, thanks, compile did the trick!

👍 1
danielneal09:10:48

I used it for a whole bunch of things, one example was to merge in responses for the open api docs. e.g. 400 - incorrect and 500 - error responses, and if :allow-unauthenticated? key on the route is false, 401 - unauthorized and 403 - forbidden.

papachan15:09:50

Hello did someone knows how i can instantiate the reitit.frontend.easy/router with React 18 ? we have ReactDOM.render method flagged as obsolete. I saw this example from reitit repository but it manage the render method from react 17. https://github.com/metosin/reitit/blob/master/examples/frontend-re-frame/src/cljs/frontend_re_frame/core.cljs

wevrem00:09:38

I tried this on my project, but it broke hot-reload. Anyone else experience that?

papachan11:09:47

@UTFAPNRPT is it your project with lein-figwheel or shadows-cljs? bc i have the hotreload code feature working with shadow.

Roma13:09:07

For me hot-reload works with shadow-cljs, but sometimes I have to refresh a browser page manually. I assume it's due to defonce .

wevrem14:09:23

@U1ZJ06MMK my project is shadow. I did some searching here in clojurians and it seems like others have experienced the issue as well. @U01320BR6US I have to refresh the page every time. That’s just not tenable. For now I’m back on 17.

wevrem03:03:08

This is great stuff. I never had an issue with my reitit fe router, at least, I never noticed it. I probably haven’t changed my route definitions much, and when I did, I must have just did a hard reload. This is good info to watch out for in future.