Skip to content

Commit

Permalink
Merge branch 'heimweah-ah/configurable-endpoint'
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott McAllister committed Oct 2, 2019
2 parents ca0ebf5 + 3bd9913 commit f60f4fc
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ var defaultHTTPClient HTTPClient = newDefaultHTTPClient()

// Client wraps http client
type Client struct {
authToken string
authToken string
apiEndpoint string

// HTTPClient is the HTTP client used for making requests against the
// PagerDuty API. You can use either *http.Client here, or your own
Expand All @@ -96,8 +97,9 @@ type Client struct {
// NewClient creates an API client
func NewClient(authToken string) *Client {
return &Client{
authToken: authToken,
HTTPClient: defaultHTTPClient,
authToken: authToken,
apiEndpoint: apiEndpoint,
HTTPClient: defaultHTTPClient,
}
}

Expand Down Expand Up @@ -130,7 +132,7 @@ func (c *Client) get(path string) (*http.Response, error) {
}

func (c *Client) do(method, path string, body io.Reader, headers *map[string]string) (*http.Response, error) {
endpoint := apiEndpoint + path
endpoint := c.apiEndpoint + path
req, _ := http.NewRequest(method, endpoint, body)
req.Header.Set("Accept", "application/vnd.pagerduty+json;version=2")
if headers != nil {
Expand Down

0 comments on commit f60f4fc

Please sign in to comment.