Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clojure Ring wrap-reload is not working

Tags:

clojure

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.

like image 510
Babistalikesflyingonrails Avatar asked Oct 18 '22 15:10

Babistalikesflyingonrails


1 Answers

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)
like image 121
birdspider Avatar answered Oct 21 '22 03:10

birdspider