August 2014
Intermediate to advanced
120 pages
2h 45m
English
Like most of James Reeves’ libraries, Compojure[22] inspires us to strive for elegance in our own work. If you’ve done any web work with Clojure, at some point you’ve probably used Compojure, on top of Ring,[23] to handle your HTTP routing. A typical app using Compojure starts out something like this:
| apis/compojure_1.clj | |
| | (ns hello-world |
| | (:require [compojure.core :refer [defroutes GET]] |
| | [compojure.route :refer [not-found]])) |
| | |
| | (defroutes app |
| | (GET "/" [] "Hello World") |
| | (not-found "Page not found")) |
Before we look at the implementations of the Compojure bits that we’re using, take a moment to consider how concise this code is. Beyond the opening ns form, we need only a few lines of code (plus a bit of wiring in the
Read now
Unlock full access