Fork me on GitHub
#reitit
<
2022-09-28
>
aaron5118:09:06

I’m struggling to create a basic retitit-ring app that works with wrap-reload — tried a lot of permutations but file changes to "1234" aren’t reflected in a browser refresh. Can you see what’s wrong here?

(ns 
  (:require
   [reitit.ring :as ring]))

(def app
  (ring/ring-handler
   (ring/router
    [["/"
      {:get {:handler
             (constantly {:body "1234"
                          :headers {"Content-Type" "text/html"}
                          :status 200})}}]])
                     (ring/create-default-handler)))

;; separate file

(ns hello.server
  (:require
   [reitit.ring :as ring]
   [ :refer [app]]
   [ring.middleware.reload :refer [wrap-reload]]
   [ring.adapter.jetty :refer [run-jetty]]))

(defn -main [& _args] (run-jetty (ring/routes (wrap-reload #'app)) {:join? false :port 3000}))

aaron5118:09:09

Thanks @U6N4HSMFW, I’ll try to grok this

valtteri18:09:27

Yeah, hope there are some clues! Though I think that wrap-reload should also ‘just work’ because it reloads the whole namespace which should cause the route-tree to be rebuilt

aaron5119:09:01

I’d be happy to (wastefully) reload everything if I could get it to work! :woman-shrugging:

aaron5119:09:09

I will gist this once it works to save myself some time next time

aaron5119:09:58

Think I got it. I have nonstandard :source-dirs! wrap-reload defaults to src only. Thank you 🙏 https://github.com/ring-clojure/ring/blob/master/ring-devel/src/ring/middleware/reload.clj#L34

valtteri19:09:06

Oh my! I My advice didn’t really help at all but glad you got it figured out. 🙂

🙏 1