Skip to content

Commit b48f27a

Browse files
authored
Merge pull request #7 from dapi-co/fix/timeouts-5min-wrong-branch
CS-1397: add 5 minute timeout to client
2 parents cc2531f + 6c5f685 commit b48f27a

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

request/request.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"bytes"
55
"io/ioutil"
66
"net/http"
7+
"time"
78

89
"github.com/dapi-co/dapi-go/constants"
910
"github.com/dapi-co/dapi-go/response"
@@ -83,7 +84,7 @@ type BaseHeader struct {
8384
// with the body of the request set as the provided body, and the headers as the
8485
// provided headers.
8586
func DapiRequest(body []byte, action string, header http.Header) ([]byte, error) {
86-
client := http.Client{}
87+
client := http.Client{Timeout: 5 * time.Minute}
8788

8889
url := constants.DAPI_URL.BASE_URL + action
8990

@@ -117,7 +118,7 @@ func DapiRequest(body []byte, action string, header http.Header) ([]byte, error)
117118
// return the response body and nil, if no errors happened, otherwise it returns
118119
// nil and the error happened.
119120
func DapiSDKRequest(body []byte, header http.Header) ([]byte, error) {
120-
client := http.Client{}
121+
client := http.Client{Timeout: 5 * time.Minute}
121122

122123
request, err := http.NewRequest("POST", constants.DD_URL, bytes.NewBuffer(body))
123124
if err != nil {

0 commit comments

Comments
 (0)