Skip to content

Commit

Permalink
Merge pull request #24 from gengo/master
Browse files Browse the repository at this point in the history
Use default transport to close connections, set timeout at client
  • Loading branch information
eddiezane committed May 2, 2015
2 parents d22c810 + 364680a commit 37fccec
Showing 1 changed file with 2 additions and 9 deletions.
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.2.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 @@ -98,11 +93,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

0 comments on commit 37fccec

Please sign in to comment.