-
-
Save andrewvc/af4daaf57ae9ce19d824 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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