Skip to content

Instantly share code, notes, and snippets.

@oliyh
Created October 6, 2015 18:33
Show Gist options
  • Save oliyh/2202e92e058862988dbc to your computer and use it in GitHub Desktop.
Save oliyh/2202e92e058862988dbc to your computer and use it in GitHub Desktop.
Pedestal interceptor which allows you to return core.async channels from defhandlers
(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