add Timeout to httpClient

This commit is contained in:
Dawid Wysokiński 2020-06-21 17:21:40 +02:00
parent 3e436ae3f7
commit abf60bdf85
1 changed files with 5 additions and 2 deletions

View File

@ -4,6 +4,7 @@ import (
"fmt"
"io/ioutil"
"net/http"
"time"
"github.com/Kichiyaki/gqlgen-client/client"
)
@ -74,8 +75,10 @@ type SDK struct {
func New(url string) *SDK {
sdk := &SDK{
url: url,
httpClient: &http.Client{},
url: url,
httpClient: &http.Client{
Timeout: 10 * time.Second,
},
}
sdk.client = client.New(http.HandlerFunc(sdk.doRequest))
sdk.LangVersions = &LangVersions{sdk}