clojure-liberator/liberator — pull request #47 by tank157 (2013-06-06 22:40:01+00:00)
Title: enable decisions to return functions as well as truthy values

Small change to core.clj which allows a decision to return a function in the truthy position, thus allowing the execution path to be altered beyond the preset values. Also by exposing defhandler, new handlers can be defined and the execution path can be altered to use these new handlers. In this manner, for instance, someone can create and use a handler to handle the 422 unprocessable entity code.

To see more, check out examples/clj/splice.clj which introduces new decision points that an application might use to test the validity of posted or put data and direct to a new unprocessable-entity handler if validation fails.

Ultimately I wanted a way to redefine decisions in the context of my application, but the nature of how they are created prevents this without larger changes. This solution was the simplest way I could see to retain the speed advantage of a largely static execution path.