Skip to content

Commit

Permalink
Refactored doRequest to utilize doRequestDetailed
Browse files Browse the repository at this point in the history
  • Loading branch information
BrooksCunningham committed Jun 27, 2023
1 parent 02d9d89 commit 7f9e54c
Showing 1 changed file with 1 addition and 29 deletions.
30 changes: 1 addition & 29 deletions api.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,34 +75,7 @@ func (sc *Client) authenticate(email, password string) error {
}

func (sc *Client) doRequest(method, url, reqBody string) ([]byte, error) {
client := &http.Client{}

var b io.Reader
if reqBody != "" {
b = strings.NewReader(reqBody)
}

req, err := http.NewRequest(method, apiURL+url, b)
if err != nil {
return []byte{}, err
}

if sc.email != "" {
// token auth
req.Header.Set("X-API-User", sc.email)
req.Header.Set("X-API-Token", sc.token)
} else {
req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", sc.token))
}

if sc.fastlyKey != "" {
req.Header.Set("Fastly-Key", sc.fastlyKey)
}

req.Header.Add("Content-Type", "application/json")
req.Header.Set("User-Agent", "go-sigsci")

resp, err := client.Do(req)
resp, err := sc.doRequestDetailed(method, url, reqBody)
if err != nil {
return []byte{}, err
}
Expand Down Expand Up @@ -2920,7 +2893,6 @@ func (sc *Client) doRequestDetailed(method, url, reqBody string) (*http.Response
resp, err := client.Do(req)

return resp, err

}

// CreateOrUpdateEdgeDeployment initializes the Next-Gen WAF deployment in Compute@Edge and configures the site for Edge Deployment.
Expand Down

0 comments on commit 7f9e54c

Please sign in to comment.