| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Polysemy.Http.Http
Description
Synopsis
- streamResponse :: Members [Http c, Error HttpError, Resource] r => Request -> (forall x. StreamEvent o c h x -> Sem r x) -> Sem r o
Documentation
streamResponse :: Members [Http c, Error HttpError, Resource] r => Request -> (forall x. StreamEvent o c h x -> Sem r x) -> Sem r o Source #
Initiate a request and stream the response, calling process after connecting, for every chunk, after closing the
connection, and for the return value.
StreamEvent is used to indicate the stage of the request cycle.
handle ::
StreamEvent Double (IO ByteString) Int a ->
Sem r a
handle = \case
StreamEvent.Acquire (Response status body headers) ->
pure 1
StreamEvent.Chunk handle (StreamChunk c) ->
pure ()
StreamEvent.Result (Response status body headers) handle ->
pure 5.5
StreamEvent.Release handle ->
pure ()
>>>runInterpreters $ streamResponse (Http.get "host.com" "path/to/file") handle5.5