Extend Ring

Ring provides a simple base for handling the HTTP request and response cycle. We’ll now look at several libraries that provide many additional utility functions that extend the functionality of Ring.

As we saw earlier, the Ring stack consists of a chain of middleware functions. Each function accepts the request map, modifies it in some way, and then passes it on to the next function in the chain. The middleware functions have to be wrapped in order of dependency. For example, session-based authentication relies on the presence of a session, and the session middleware must run before it to make the session available.

A library called ring-defaults provides a standard set of middleware that’s useful for typical web applications. ...

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

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