I've been taking a look at compojure 0.4, and have been having some
trouble getting started.
It appears that the new method of web server is to use ring's
adapters, as the 0.4 branch seems to have removed the jetty-server
function.
No bother, as ring supplies ring.adapter.jetty/run-jetty function,
unfortunately though it's behaviour doesn't seem to encourage lisp
style interactive development.
I have the following code taken from rings hello_world example:
(ns ring.example.hello-world
(:use ring.adapter.jetty)
(:import java.util.Date java.text.SimpleDateFormat))
(defn app
[req]
{:status 200
:headers {"Content-Type" "text/html"}
:body (str "<h3>Hello World from Ring</h3>"
"<p>The current time is "
(.format (SimpleDateFormat. "HH:mm:ss") (Date.))
".</p>")})
(run-jetty app {:port 8080})
Running this code works, however once its running modifying the
definition of the app function (e.g. changing it to say "Hello Rick")
and re-evaluating the form in Emacs/SLIME doesn't cause the changes to
propogate into Jetty. Also re-evaluating the whole file fails as
jetty's socket is left open.
I believe the ability to redefine functions and have them
automagically be deployed was a feature of Compojure 0.3.2. What is
the preferred way to do this now?
Thanks for your help,
R.
p.s. I hope you don't mind the cross-post, but I'm not sure where this
responsibilty lies...
Sorry to hear that you've been having trouble. You might find the
following helpful:
The short answer is that (run-jetty (var app)) will solve your
problem.
Let me know if you have any other difficulties with reloading.
- Mark
Thanks a lot for this!
R.