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:
$$
with $$+-
Solved with
server :: Server API
server = do
env <- newEnv Discover
res <- runInternalState (runAWS env conduits) st
return (res >> liftIO (closeInternalState st))
https://github.com/domenkozar/servant-streaming-amazonka/commit/c5fad78dd7bf733cecb8790035105c819d5f5ae9
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With