Skip to content

Commit da148d8

Browse files
committed
Set Timeout for http.Client
1 parent a951423 commit da148d8

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

client.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"net/url"
2121
"runtime"
2222
"strings"
23+
"time"
2324
)
2425

2526
const (
@@ -28,6 +29,9 @@ const (
2829

2930
// Endpoint points you to MessageBird REST API.
3031
Endpoint = "https://rest.messagebird.com"
32+
33+
// httpClientTimeout is used to limit http.Client waiting time.
34+
httpClientTimeout = 15 * time.Second
3135
)
3236

3337
const (
@@ -63,7 +67,12 @@ type Client struct {
6367

6468
// New creates a new MessageBird client object.
6569
func New(AccessKey string) *Client {
66-
return &Client{AccessKey: AccessKey, HTTPClient: &http.Client{}}
70+
return &Client{
71+
AccessKey: AccessKey,
72+
HTTPClient: &http.Client{
73+
Timeout: httpClientTimeout,
74+
},
75+
}
6776
}
6877

6978
// Request is for internal use only and unstable.

0 commit comments

Comments
 (0)