I've created a new Compojure Leiningen project using lein new compojure test
. Web server is run by lein repl
and then
user=> (use 'ring.adapter.jetty)
user=> (run-jetty test.handler/app {:port 3000})
Routes and app handler specification is trivial:
(defroutes app-routes
(GET "/*.do" [] "Dynamic page")
(route/not-found "Not Found"))
(def app
(wrap-defaults app-routes site-defaults))
Now, after changing anything in app-routes
definition (e.g. changing "Dynamic page" text to anything else, or modifying URI matching string), i do not get the updated text/routes in the browser. But, when changing app-routes
definition slightly to
(defn dynfn [] "Dynamic page fn")
(defroutes app-routes
(GET "/*.do" [] (dynfn))
(route/not-found "Not Found"))
i do get dynamic updates when changing the return value of dynfn
. Also, following the advice from this article and modifying the app
definition to
(def app
(wrap-defaults #'app-routes site-defaults))
(note the #'
that transparently creates a var for app-routes
) also helps!
Why is that so? Is there any other way one could get a truly dynamic behaviour in defroutes
?
Thanks!