Created
October 6, 2015 18:33
-
-
Save oliyh/2202e92e058862988dbc to your computer and use it in GitHub Desktop.
Pedestal interceptor which allows you to return core.async channels from defhandlers
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
(swagger/defafter async-handler | |
{:description "Wraps asynchronous responses into the context (lets you use defhandler)"} | |
[context] | |
(if (satisfies? clojure.core.async.impl.protocols/Channel (:response context)) | |
(a/pipe (:response context) (a/chan 1 (map #(assoc context :response %)))) | |
context)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment