Clojure reloading rings not working

This is my core.clj file

(ns lein-app.core
  (:require [compojure.core :refer :all]
            [compojure.route :as route]
            [ring.middleware.reload :refer [wrap-reload]]))

(use 'ring.adapter.jetty)

(defroutes app
  (GET "/" [] "<h1>Hello world</h1>")
  (route/not-found "<h1>Not found</h1>"))

(def reloadable-app
  (wrap-reload app))

(defn -main
  []
  (run-jetty reloadable-app {:port 3000}))

And this is my .clj project

(defproject lein-app "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [
    [org.clojure/clojure "1.8.0"]
    [compojure "1.5.2"]
    [ring "1.5.0"]]

  :main lein-app.core)

When I start lein, it starts the server correctly, but if I change the GET response to something else, for example, I need to kill the server and restart it.

+4
source share
1 answer

as indicated in the ring issue # 104 , the document is not entirely clear.

For wrap-reload(and also for similar functionality in other libs / projects) it is necessary to pass the value of var, not the value.

In this way

(wrap-reload #'app)
+3
source

Source: https://habr.com/ru/post/1673425/


All Articles