Added client timeout because http.DefaultClient doesn't have timeout

This commit is contained in:
Junpei Tsuji
2018-05-18 12:18:09 +09:00
parent cdb4cd7c54
commit 8e67f122c0
6 changed files with 34 additions and 21 deletions

View File

@@ -7,6 +7,7 @@ import (
"fmt"
"net/http"
"os"
"time"
)
const (
@@ -55,9 +56,11 @@ type Client struct {
// New creates a client object
func New(secret string) *Client {
client := &Client{
URL: getSandboxURL(),
Secret: secret,
httpCli: http.DefaultClient,
URL: getSandboxURL(),
Secret: secret,
httpCli: &http.Client{
Timeout: 10 * time.Second,
},
}
if os.Getenv("IAP_ENVIRONMENT") == "production" {
client.URL = ProductionURL