Saturday, October 15, 2016

Run Clojure Ring App Using Boot

Boot is a Clojure build framework. Here is an example of a basic ring application that is run using boot. The project folder is shown below.
| build.boot
(ns qlambda.server.core
(:require [ring.adapter.jetty :as jetty]))

(defn handler [req]
{:status 200
:body "Hello World"})

(defn -main [& args]
(jetty/run-jetty handler {:port 8080}))
:source-paths #{"src"}
:dependencies '[[org.clojure/clojure "1.8.0"]
[ring "1.5.0"]])

(require '[qlambda.server.core :as server])

(deftask run []
(with-pre-wrap fileset (server/-main) fileset))
To run go to the project root directory and execute
boot run
Go to http://localhost:8080 to see the response.