Liberator is a Clojure library that helps you expose your data as resources while automatically complying with all the relevant requirements of the HTTP specification (RFC-2616). Your resources will automatically gain useful HTTP features, such as caching and content negotiation. Liberator was inspired by Erlang’s Webmachine. By following the constraints and requirements in RFC-2616, liberator will enable you to create application according to a REST architecture.
Liberator resources are ring handlers and fit nicely into Ring, the defacto Clojure web development environment. Typically you will use liberator together with a routing library like compojure and a library to generate the resources’ representations. The representations may be in HTML, generated with a library like hiccup, or they could be represented in something like JSON or XML by using the appropriate libraries.
For more Information about adding the web server component required for liberator, see the Ring documentation.
Add the liberator dependency to your project.clj:
Define your first resource using
(ns example (:use [liberator.core :only [defresource]])) (defresource hello-world :available-media-types ["text/plain"] :handle-ok "Hello, world!")
Forget “big data”, there is a lot of useful data locked up in “big applications”. Many of these applications, especially in large organizations, are written in Java.
Clojure can run side-by-side with Java in the JVM, seamlessly accessing the same internal Java APIs that your Java application does. That makes Clojure a great choice for developing new facades onto your application stack and liberating your data in an HTTP compliant manner.