This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-05-20
Channels
- # aleph (11)
- # announcements (3)
- # babashka (35)
- # babashka-sci-dev (28)
- # beginners (29)
- # calva (51)
- # cider (33)
- # clj-kondo (26)
- # clj-on-windows (1)
- # clojure (40)
- # clojure-austin (1)
- # clojure-europe (47)
- # clojure-nl (9)
- # clojure-norway (7)
- # clojure-uk (5)
- # clojurescript (69)
- # conjure (30)
- # cursive (7)
- # data-science (9)
- # datomic (2)
- # etaoin (10)
- # events (2)
- # fulcro (1)
- # graalvm (1)
- # gratitude (6)
- # helix (16)
- # honeysql (20)
- # hyperfiddle (14)
- # inf-clojure (2)
- # jobs (1)
- # jobs-discuss (12)
- # kaocha (9)
- # leiningen (2)
- # lsp (4)
- # malli (8)
- # music (9)
- # off-topic (12)
- # pathom (10)
- # portal (14)
- # practicalli (15)
- # re-frame (27)
- # reitit (7)
- # remote-jobs (4)
- # sci (37)
- # shadow-cljs (16)
- # sql (8)
- # tools-deps (6)
- # vim (6)
- # xtdb (21)
I decided to go back to basics in order to gain a better understanding of reitit-pedestal
, but I've got stuck at first base 😳
With the following minimal src/core.clj
https://gist.github.com/codeasone/950b5cd936ed0fffc4ab02d53afcd0d4, and having jacked-in to cider and evaluated (start)
, I was expecting to be able to modify/eval just the
hello
handler and reload http://localhost:8080/hello to see any changes I've made reflected, but no dice. Likewise, I can't just instrument hello
in cider
as I do usually and reload in the browser to start step debugging the handler.
Would anyone be kind enough to point out what am I missing here? I've looked at the reitit
example code which follows a similar pattern to my minimal example, and I've also dug a bit into the router-interceptor
code, but I can't find a way to make things dynamic in the way I'd expect. Apologies in advance if this is blindingly obvious.
This page from the docs may be useful: https://cljdoc.org/d/metosin/reitit/0.5.18/doc/advanced/dev-workflow likewise https://clojure.org/guides/repl/enhancing_your_repl_workflow#writing-repl-friendly-programs
Hi @UG00LE5TN I did have a read through that document but none of the points raised seemed to help me resolve my particular issue. Maybe there's another way of establishing the routing interceptor which would allow me to benefit from the advice given:
> calling a function rather than just passing router
to the matching function...
I read through the underlying code and couldn't figure out a way forward since the match-for-path
invocation in the library code is taking a router
and not doing anything smart like determining whether if was callable or not.
Caveat that this is just from looking at the code and having worked with interceptors some time ago, but the first approach I'd try is providing a development version of pedestal/routing-interceptor
(which you'd continue using in prod).
This dev-routing-interceptor
would on :enter
construct and enqueue a fresh pedestal/routing-interceptor
, calling (routes)
to get the latest version of your routes.
Something like this:
(defn routing-interceptor
[]
(interceptor-helpers/before
(fn [ctx]
(chain/enqueue ctx [(pedestal/routing-interceptor (r/router (routes)))]))))
(defn start []
(println "Server started")
(reset! server
(-> service-map
http/default-interceptors
(update ::http/interceptors #(conj % (routing-interceptor)))
http/create-server
http/start)))
works for my purposes, but I'm surprised this isn't supported in a more direct way by the library.