Skip to content

Instantly share code, notes, and snippets.

Created March 12, 2015 19:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/e20aab497cd0262beb6a to your computer and use it in GitHub Desktop.
Save anonymous/e20aab497cd0262beb6a to your computer and use it in GitHub Desktop.
Using as-response for a custom json encoder in liberator
(defresource bananas
:available-media-types ["application/edn" "application/json"]
:handle-ok (fn [_] {:represent :me :value (java.util.Date.)})
:as-response (fn [d ctx] (if (= "application/json" (get-in ctx [:representation :media-type]))
(whatever/to-json d)
(liberator.representation/as-response d ctx))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment