January 2014
Intermediate to advanced
232 pages
5h 11m
English
Liberator uses the concept of resources to interact with the client. The resources are simply Ring-compliant handlers that can be used inside your Compojure routes. These resources are defined using the resource and defresource macros. Let’s open the liberator-service.routes.home namespace. We’ll remove the reference to layout and add the references for resource and defresource to the declaration:
| liberator-snippets/home.clj | |
| | (ns liberator-service.routes.home |
| | (:require [compojure.core :refer :all] |
| | [liberator.core |
| | :refer [defresource resource request-method-in]])) |
Now we can replace our "/" route with a resource as follows:
| liberator-snippets/home.clj | |
| | (defroutes home-routes |
| | (ANY "/" request |
| | (resource |
| | :handle-ok ... |
Read now
Unlock full access