-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Labels
Description
HTTPotion and HTTPoison both wrap responses in similar structs. Considering an (optional?) struct for mapping responses, using the existing structure.
This seems like it'd work well for when you want the body directly, but poorly for fine grained response handling, like streaming. For example, HTTPoison wants the entire struct passed in as part of an {:async :once} request.
It seems like we'd need at least these structs to cover all cases.
# most cases are async.
HttpBuilder.AsyncChunk
HttpBuilder.AsyncEnd
HttpBuilder.AsyncHeaders
HttpBuilder.AsyncRedirect
HttpBuilder.AsyncResponse
HttpBuilder.AsyncStatus
HttpBuilder.AsyncRawRequest
HttpBuilder.AsyncTimeout
# but small apis can just await a response.
HttpBuilder.Response A possible top-level implementation, adding an options argument to HttpBuilder.send/1
client()
|> get("/items")
|> send([map: true])Or as a new method altogether.
client()
|> get("/items")
|> send()
|> map()