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.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With