Skip to content

Instantly share code, notes, and snippets.

@neotyk
Created September 12, 2011 22:22
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 neotyk/1212643 to your computer and use it in GitHub Desktop.
Save neotyk/1212643 to your computer and use it in GitHub Desktop.
(defmacro json-flash [method path params body]
(let [flash# (gensym "flash")
params# (assoc params flash# :flash)]
`(~method ~path ~params#
(let [r# (do ~@body)
r# (if-not (empty? ~flash#)
(assoc r# :flash ~flash#)
r#)]
(-> r#
json/encode-to-str
response/response
(response/content-type "application/json"))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment