clojure-liberator/liberator — pull request #97 by stijnopheide (2014-01-09 17:55:23+00:00)
Title: Add possibility for reuse to defresource

Adding the possibility for reuse as discussed on the mailing list

see https://groups.google.com/forum/#!topic/clojure-liberator/CKl2lPp-3ZY

example usage:

```clojure
;; still compatible with the old format
(defresource without-param
:handle-ok (fn [_] (format "The text is %s" "test")))

(defresource parameter [txt]
:handle-ok (fn [_] (format "The text is %s" txt))
:available-media-types ["application/xml"])

;; how to introduce reuse
(def standard-config
{:available-media-types ["application/json"]})

(defresource with-options
standard-config
:handle-ok (fn [_] (format "The text is %s" "this")))

(defresource with-options-and-params [txt]
standard-config
:handle-ok (fn [_] (format "The text is %s" txt))
:available-media-types ["application/xml"]) ;; this actually overrides the standard-config

;; you can also add a parametrized config
(defn parametrized-config
[media-type]
{:available-media-types [media-type]})

(defresource with-options-parametrized-config [media-type txt]
(parametrized-config media-type)
:handle-ok (fn [_] (format "The text is %s" txt)))
```