I'd like to be able to stream S3 bucket object contents via Servant as the response body.
I'm having issues getting MonadResource instance missing for Handler:
src/Servant/Streaming/Example.hs:29:3: error:
* No instance for (MonadResource Handler)
arising from a use of `runAWS'
* In a stmt of a 'do' block: runAWS env conduits
In the expression:
do env <- newEnv Discover
runAWS env conduits
In an equation for `server':
server
= do env <- newEnv Discover
runAWS env conduits
|
29 | runAWS env conduits
| ^^^^^^^^^^^^^^^^^^^
I have made a repository to reproduce: https://github.com/domenkozar/servant-streaming-amazonka
servant-streaming-server
handles ResourceT
for Stream (Of BS.ByteString) (ResourceT IO) ()
https://github.com/plow-technologies/servant-streaming/blob/master/servant-streaming-server/src/Servant/Streaming/Server/Internal.hs#L77-L79
but since I'm using Amazonka I also need to make sure MonadResource for Handler is taken take in that bracket. It's not clear to me how to do that.
My understanding is that using enter
/hoistServer
this won't work since resources would be cleaned up too soon (before streaming).
Notes:
- This builds upon question asked in 2016: Haskell Servant and streaming
- Servant part is implemented via https://github.com/plow-technologies/servant-streaming/pull/2/files
Edits
- EDIT: I've since replaced
$$
with$$+-
- EDIT2: I've resolved Conduit specific errors, now fighting with MonadResource