April 15th, 2010
Installing Compojure
Topics: Compojure, Clojure, HowtoThe Clojure webframework Compojure is dead easy to install and get running but I got stuck. Anyway it's working now and here are the steps I took:
Install Leiningen (as root)
cd /usr/local/bin/ wget http://github.com/technomancy/leiningen/raw/stable/bin/lein chmod a+x lein
Setup Leningen and install Compojure (as user)
lein self-install git clone git://github.com/weavejester/compojure.git cd compojure lein deps lein jar cp compojure.jar ~/.swank-clojure/ cp libs/* ~/.swank-clojure/
(~/.swank-clojure/ is inside my classpath because I use Emacs, replace that with the correct directory for your installation.)
Now a trial program straight from the Compojure homepage
(use 'compojure.core 'ring.adapter.jetty)
(defroutes main-routes
(GET "/" []
"<h1>Hello World</h1>")
(ANY "*" []
{:status 404, :body "<h1>Page not found</h1>"}))
(run-jetty main-routes {:port 8080})
Now browse to http://localhost:8080 and it should say "Hello World".
Cheers, Dave.