Skip to content

Commit

Permalink
SetRequestTimeout init the http.Client if nil
Browse files Browse the repository at this point in the history
  • Loading branch information
mileusna committed Jun 4, 2018
1 parent 6ce1946 commit b816488
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion viber.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ type Viber struct {
Seen func(v *Viber, userID string, token uint64, t time.Time)
Failed func(v *Viber, userID string, token uint64, descr string, t time.Time)

// client for sendint messages
// client for sending messages
client *http.Client
}

Expand Down Expand Up @@ -218,5 +218,8 @@ func peakMessageType(b []byte) string {

// SetRequestTimeout for sending messages to viber server
func (v *Viber) SetRequestTimeout(t time.Duration) {
if v.client == nil {
v.client = &http.Client{}
}
v.client.Timeout = t
}

0 comments on commit b816488

Please sign in to comment.