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

Introduce an interface instead of requiring a concrete *http.Client type #146

Closed
Dynom opened this issue Jun 14, 2016 · 1 comment
Closed
Assignees
Labels
🚨 This issue needs some love. triage me I really want to be triaged.

Comments

@Dynom
Copy link

Dynom commented Jun 14, 2016

To add more flexibility when it comes to HTTP clients, I propose to accept an Interface rather than a concrete type for the services.

An interface as suggested by @odeke-em in #142 (comment) and golang/go#16047

type HTTPClient interface {
    Do(req *http.Request) (res *http.Response, err error)
    Get(url string) (res *http.Response, err error)
    Post(urstring, bodyType string, body io.Reader) (res *http.Response, err error)
    PostForm(url string, values url.Values) (res *http.Response, err error)
    Head(url string) (res *http.Response, err error)
    // Add any other methods here if necessary
}

This would solve #142 and more issues as it would allow for more freedom in specifying (more robust) http clients. I'm more than willing to add a PR, if this project accepts public PR's.

@bradfitz
Copy link
Contributor

I don't think this is a direction we want to take.

The http.RoundTripper interface already exists for defining your own transports. The *http.Client is a concrete type specifically to add helper methods (like PostForm) around an underlying HTTP transport.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚨 This issue needs some love. triage me I really want to be triaged.
Projects
None yet
Development

No branches or pull requests

3 participants