Define the Routes with Compojure

Compojure is a routing library built on top of Ring. It provides a way to associate handler functions with a URL and an HTTP method. Let’s add it as a dependency in the ring-app project and see how it works.

 (defproject ring-app ​"0.1.0-SNAPSHOT"
  :description ​"FIXME: write description"
  :url ​""
  :license {:name ​"Eclipse Public License"
  :url ​""​}
  :dependencies [[org.clojure/clojure ​"1.7.0"​]
  [ring ​"1.4.0"​]
  [metosin/ring-http-response ​"0.6.5"​]
  [ring-middleware-format ​"0.7.0"​]
  [compojure ​"1.4.0"​]]
  :main ring-app.core)

With the dependency in place, let’s update the namespace to reference compojure.core ...

Get Web Development with Clojure, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.