2017-05-04 19:35 GMT+02:00 Brian Craft <[email protected]>:
>
> If there's only one with-open it can be reasonably simple to pass the
> consumer into that context (though from ring it's pretty convoluted, due to
> needing to pass control to ring first).
>
Creating streamed ring responses can be kind of tricky. In my experience,
there are two patterns, that work well:
1) Feeding a PipedInputStream from a new thread:
(let [os (PipedOutputStream.)
is (PipedInputStream. os)]
(future (with-open [rs ...]
(write-to! os rs)))
{:body is})
2) Use a ring adapter that allows some form of asynchronous response. E.g.
with the new ring 1.6 model
{:body (reify ring.core.protocols/StreamableResponseBody
(write-body-to-stream [_ _ output-stream]
(with-open [rs ...
os output-stream]
(write-to! os rs))))}
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.