Skip to content

Instantly share code, notes, and snippets.

@andrewvc
Created December 23, 2011 22:00
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 andrewvc/af4daaf57ae9ce19d824 to your computer and use it in GitHub Desktop.
Save andrewvc/af4daaf57ae9ce19d824 to your computer and use it in GitHub Desktop.
(defmacro defpage-async
[path request-bindings ch-binding & body]
`(custom-handler ~path request-bindings
(wrap-aleph-handler
(fn [ch# ~ch-binding _]
(letfn [(respond [response] (enqueue-and-close ch# response))
(on-receive [handler] (receive-all ch# handler))
(on-close [handler] (on-closed ch# handler))]
(let [~ch-binding ch#] ~@body))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment