Skip to content

Commit

Permalink
Merge pull request #4 from deantgao/master
Browse files Browse the repository at this point in the history
Enable custom HTTP client
  • Loading branch information
kevalds51 authored Feb 25, 2022
2 parents fa594f7 + 1520aa2 commit e344d1f
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions victorops/victorops.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"io/ioutil"
"net/http"
"net/http/httputil"
"time"
)

// Client is the main client for interacting with victorops
Expand Down Expand Up @@ -85,19 +84,17 @@ func (c Client) makePublicAPICall(method string, endpoint string, requestBody io

// NewClient creates a new VictorOps client
func NewClient(apiID string, apiKey string, publicBaseURL string) *Client {
args := ClientArgs{timeoutSeconds: 30}
return NewConfigurableClient(apiID, apiKey, publicBaseURL, args)
return NewConfigurableClient(apiID, apiKey, publicBaseURL, http.Client{Timeout: 30})
}

// NewConfigurableClient creates a new VictorOps client with ClientArgs struct
func NewConfigurableClient(apiID string, apiKey string, publicBaseURL string, args ClientArgs) *Client {
func NewConfigurableClient(apiID string, apiKey string, publicBaseURL string, httpClient http.Client) *Client {
client := Client{
apiID: apiID,
apiKey: apiKey,
publicBaseURL: publicBaseURL,
httpClient: http.Client{Timeout: time.Duration(args.timeoutSeconds) * time.Second},
httpClient: httpClient,
}

return &client
}

Expand Down

0 comments on commit e344d1f

Please sign in to comment.