Skip to content

Commit

Permalink
add: reset only 1 URL
Browse files Browse the repository at this point in the history
  • Loading branch information
CorentinB committed Dec 11, 2024
1 parent f0a189e commit 81aacf8
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions reset.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,32 @@ func (c *Client) Reset() (err error) {

return nil
}

func (c *Client) ResetURL(ID string) (err error) {
expectedStatusCode := 200

req, err := http.NewRequest(http.MethodPost, c.ResetEndpoint.String()+"/"+ID, nil)
if err != nil {
return err
}

req.Header.Add("X-Auth-Key", c.Key)
req.Header.Add("X-Auth-Secret", c.Secret)
req.Header.Add("User-Agent", "gocrawlhq/"+Version)

if c.Identifier != "" {
req.Header.Add("X-Identifier", c.Identifier)
}

resp, err := c.HTTPClient.Do(req)
if err != nil {
return err
}
defer resp.Body.Close()

if resp.StatusCode != expectedStatusCode {
return fmt.Errorf("non-%d status code: %d", expectedStatusCode, resp.StatusCode)
}

return nil
}

0 comments on commit 81aacf8

Please sign in to comment.