Serving data with Ring and Compojure
While we can precompile ClojureScript and load the generated JavaScript files as static assets, we'll often want to combine the dynamic charts with dynamic pages. For instance, we might want to provide a search form to filter the data that's graphed.
In this recipe, we'll get started with a typical Clojure web stack. Even if we don't use ClojureScript, this system is useful for creating web applications. We'll use Jetty (http://jetty.codehaus.org/jetty/) to serve the requests, Ring (https://github.com/ring-clojure/ring) to connect the server to the different parts of our web application, and Compojure (http://compojure.org) to define the routes and handlers.
Getting ready
We'll first need to include Jetty, Ring, and Compojure in our Leiningen project.clj
file. We'll also want to use Ring as a development plugin for this project, so let's include it in the project.clj
file under the :plugins
key. The following is the...