Clojure Ring wrap-reload is not working

若如初见. 提交于 2021-01-27 07:51:48

问题


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 project.clj

(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 run lein run it starts the server correctly but if I change the GET response to be anything else for example I need to kill the server and restart it.


回答1:


as indicated in the ring issue#104 the doc is not quite clear.

For wrap-reload (as well for similar functionality in other libs/projects) one has to pass the var itself not the value.

Like so

(wrap-reload #'app)


来源:https://stackoverflow.com/questions/43074428/clojure-ring-wrap-reload-is-not-working

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!