Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Common Struct for responses across adapters. #4

Open
matthewoden opened this issue Jan 15, 2018 · 0 comments
Open

Common Struct for responses across adapters. #4

matthewoden opened this issue Jan 15, 2018 · 0 comments

Comments

@matthewoden
Copy link
Owner

matthewoden commented Jan 15, 2018

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()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant