Fork me on GitHub

What is liberator?

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’s place in the Clojure ecosystem

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 or bidi 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.

Quickstart

Setup dependencies

Add the liberator dependency to your project.clj:

[liberator "0.15.3"]
Compatibility with prior releases is a goal but it cannot always be guaranteed. Compatibility notes are marked as follows: since 0.9.0

Define your first resource using defresource.

(ns example
  (:use [liberator.core :only [defresource]]))

(defresource hello-world
  :available-media-types ["text/plain"]
  :handle-ok "Hello, world!")

Liberating data?

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.