File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change 1+ (ns compojure.api.async
2+ (:require [compojure.response :as response]
3+ [compojure.api.common :as common]
4+ compojure.api.routes))
5+
6+ (common/when-ns 'manifold.deferred
7+ ; ; Compojure is smart enough to get the success value out of deferred by
8+ ; ; itself, but we want to catch the exceptions as well.
9+ (extend-protocol compojure.response/Sendable
10+ manifold.deferred.IDeferred
11+ (send* [deferred request respond raise]
12+ (manifold.deferred/on-realized deferred #(response/send % request respond raise) raise))))
13+
14+ (common/when-ns 'clojure.core.async
15+ (extend-protocol compojure.response/Sendable
16+ clojure.core.async.impl.channels.ManyToManyChannel
17+ (send* [channel request respond raise]
18+ (clojure.core.async/go
19+ (let [message (clojure.core.async/<! channel)]
20+ (if (instance? Throwable message)
21+ (raise message)
22+ (response/send message request respond raise)))))))
23+
24+ (extend-protocol compojure.response/Sendable
25+ compojure.api.routes.Route
26+ (send* [this request respond raise]
27+ ((.handler this) request #(response/send % request respond raise) raise)))
You can’t perform that action at this time.
0 commit comments