1 minute read

Compojure is a Clojure routing library for building web applications. When you run lein new compojure little_ring_things, you’re using it as a Leiningen project template.

Here’s what each part means:

lein new — Leiningen’s command to scaffold a new project from a template.

compojure — The template name, which sets up a basic web app skeleton pre-wired with:

  • Compojure — a DSL for defining HTTP routes (built on top of Ring)
  • Ring — Clojure’s HTTP server abstraction (like Rack in Ruby or WSGI in Python)
  • ring-jetty-adapter — embeds a Jetty server so you can run it locally

little_ring_things — Your project name.


What Compojure (the library) actually does:

It lets you define routes cleanly using macros like defroutes and GET, POST, etc.:

(defroutes app-routes
  (GET "/"     [] "Hello World")
  (GET "/about" [] "About page")
  (route/not-found "Not Found"))

Without Compojure, you’d have to manually inspect the Ring request map and match paths yourself — much more verbose.


What the generated project gives you:

little_ring_things/
├── project.clj        ← dependencies (compojure, ring, etc.)
├── src/
│   └── little_ring_things/
│       └── handler.clj   ← your routes live here
└── test/

handler.clj will have a basic route already set up and an app var that Ring/Jetty serves.

You’d start it with lein ring server (using the lein-ring plugin included in the template).


In short: Compojure is the routing layer that sits on top of Ring (the HTTP layer), and the template bootstraps a working web app with both wired together so you can start defining routes immediately.

Updated: