This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-10-23
Channels
- # announcements (3)
- # aws (2)
- # babashka (31)
- # beginners (14)
- # calva (14)
- # cider (4)
- # clj-kondo (1)
- # clojure (24)
- # clojure-europe (18)
- # clojure-gamedev (4)
- # clojure-nl (3)
- # clojure-norway (23)
- # clojurescript (24)
- # core-typed (23)
- # data-science (9)
- # datomic (1)
- # emacs (15)
- # events (4)
- # gratitude (3)
- # introduce-yourself (1)
- # leiningen (9)
- # lsp (65)
- # membrane (39)
- # music (1)
- # nbb (1)
- # obb (8)
- # reitit (17)
- # releases (1)
- # tree-sitter (2)
- # vim (28)
- # xtdb (3)
One of the things that has bugged me a bit, is that if I modify a handler and re-eval my buffer, reitit (ring?) doesn't pick up the change, unless I reload the namespaces. So, now I'm doing this:
(defn foo
[_]
{:status 200 :body "Hello World!"})
(def routes
[["/foo" {:get {:handler #'foo]])
(defn foo
[_]
{:status 200 :body "Hello World!"})
(def routes
[["/foo" {:get {:handler foo]])
Now if I modify foo
to return, say "Good Bye World", and eval the function, the changes are picked up immediately.
I put everything in functions, and the dev handler is wrapped such that a new handler is instantiated for each request
see the final point here https://cljdoc.org/d/metosin/reitit/0.5.18/doc/advanced/dev-workflow#an-easy-fix
I think there should a dev/eval mode, for better repl experience oob. Personally, using mostly integrant and reset
ing anyway after any change.
Yes, I'm at the moment using donut system and doing (ds/reset) to reload all the namespaces in, 'although much easier if I just eval a form 🙂
You can just add it as a flag when creating the handler Something I started leaning towards with Component, the more components, the better
This is little tricker than I expected. I'm trying to get this to work with a ring/ring-handler
and a ring/router
. So far I'm tried (ring/ring-handler #(ring/router routes ....
and (ring/ring-handler (ring/router #'routes....
with no joy. Either an exception is thrown when hitting a route (since the function '#(
isn't returning a router
(protocol) or nothing happens if I re-eval a route handler
Thank you one and all (shout out to @UK0810AQ2) got it all nicely working now.