Fork me on GitHub
#reitit
<
2022-03-03
>
dharrigan16:03:36

I wonder if anyone here uses reitit with juxt clip (am I the only one!?! 🙂 ) who can illumate me on how to do a dev workflow so, if I change a (function) route, and eval, I don't have t restart the system again?

Ben Sless17:03:23

I just did something similar with component, maybe you could steal ideas?

dharrigan18:03:10

I can have a looksee, but from what I've been playing around, I have to reload the system so far

dharrigan18:03:13

do you have a link?

Ben Sless18:03:57

no, but I can tell you what I did Order of dependencies for components: server -> ring-handler -> ring-router -> routes -> handlers map routes: [[path-a handler-a] ... Then in development you can pass all the handlers as vars instead of function values, or build the handlers wrapped in (fn [x] (handler x)) making sure they are referenced by name and not by value at dev time also see https://github.com/metosin/reitit/blob/master/doc/advanced/dev_workflow.md#an-easy-fix

dharrigan20:03:46

Yup, thank you. Reading that, so far, can't get it to work. Will keep plugging away at it.

Ben Sless20:03:29

I got it wrong for about three hours until I figured it out

dharrigan20:03:51

WHen you say referenced by name, not value, can you elaborate?

Ben Sless20:03:49

One way to do it is with vars, another is requiring resolve, or (fn [x] (f x)), which doesn't do anything, but is compiled in a way where f isn't passed by value

Ben Sless20:03:59

Something like (defmacro $ [f] (fn [~'x] (~f ~'x))) then when you refer to your handler which you pass to the routes do it with ($ handler)

Ben Sless20:03:07

checked it now, works as expected

dharrigan20:03:57

thank you, will give it a whirl

Ben Sless05:03:09

Do you want to share a code snippet?

dharrigan07:03:45

Sure, I'll DM you

Oliver Marks21:03:57

So I have a wild card route where I am passing in a string "one/two/three" "/posts/{*path}" with that as the route, what I am finding is rfe/href is encoding the slash in the url, which often you might want but in this case makes the links look ugly is there a way to disable this ? the links do work but posts/one%2Ftwo%2Fthere does not look as nice as posts/one/two/three.

Oliver Marks14:03:08

figured out in the end that you can just concat on the end of the function call.