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

Use default transport to close connections, set timeout at client #24

Merged
merged 1 commit into from
May 2, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions sendgrid.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package sendgrid
import (
"fmt"
"io/ioutil"
"net"
"net/http"
"net/url"
"strings"
Expand All @@ -13,10 +12,6 @@ import (

const Version = "1.1.0"

func timeoutHandler(network, address string) (net.Conn, error) {
return net.DialTimeout(network, address, time.Duration(5*time.Second))
}

// SGClient will contain the credentials and default values
type SGClient struct {
apiUser string
Expand Down Expand Up @@ -81,11 +76,9 @@ func (sg *SGClient) buildURL(m *SGMail) (url.Values, error) {
// Send will send mail using SG web API
func (sg *SGClient) Send(m *SGMail) error {
if sg.Client == nil {
transport := http.Transport{
Dial: timeoutHandler,
}
sg.Client = &http.Client{
Transport: &transport,
Transport: http.DefaultTransport,
Timeout: 5 * time.Second,
}
}
var e error
Expand Down