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

Allow for setting a custom HTTP client #9

Merged
merged 2 commits into from
Jul 28, 2016
Merged

Conversation

thinkingserious
Copy link
Contributor

No description provided.

@thinkingserious
Copy link
Contributor Author

@sridharv, @broady,

Given the hiccups with the CLA and need for a fix, I went ahead and created this pull request. I would appreciate a quick review to ensure this will do what you need.

For reference, this closes:
#5
sendgrid/sendgrid-go#63
#8
#6
sendgrid/sendgrid-go#59

@sridharv
Copy link

sridharv commented Jul 28, 2016

Looks good to me.

Thanks for porting!


func TestCustomHTTPClient(t *testing.T) {
fakeServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
time.Sleep(time.Second * 2)
Copy link

@broady broady Jul 28, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These timeouts can be shorter - try 10ms & 20ms.

@broady
Copy link

broady commented Jul 28, 2016

LGTM

BaseURL: baseURL,
}
customClient := &Client{&http.Client{Timeout: time.Second * 1}}
_, e := customClient.API(request)
Copy link

@broady broady Jul 28, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/e/err/

if _, err := customClient.API(request); err == nil {
  t.Error("got nil, want non-nil err")
}

@thinkingserious
Copy link
Contributor Author

Thanks for the feedback! I'll make the suggested changes here and get this deployed and update the dependency in sendgrid-go.

@thinkingserious
Copy link
Contributor Author

@broady @sridharv,

Thank you so much for your support and help on this!

Please send us your mailing address and T-shirt size (dx@sendgrid.com) so we can give you a small token of our appreciation.

@broady
Copy link

broady commented Jul 28, 2016

woohoo!

@childish-sambino childish-sambino deleted the default-client branch January 16, 2020 23:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants