chore: use UTC instead of GMT when possible (#2275)
This commit is contained in:
parent
d52f7b0b58
commit
0da0942081
3 changed files with 4 additions and 19 deletions
|
@ -178,17 +178,12 @@ func (c *Client) do(ctx context.Context, query url.Values, result any) error {
|
|||
}
|
||||
|
||||
func sign(apiUsername, apiKey string, query url.Values) (url.Values, error) {
|
||||
location, err := time.LoadLocation("GMT")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("time location: %w", err)
|
||||
}
|
||||
|
||||
timestamp := time.Now().In(location).Format("2006-01-02T15:04:05Z")
|
||||
timestamp := time.Now().UTC().Format("2006-01-02T15:04:05Z")
|
||||
|
||||
canonicalRequest := fmt.Sprintf("%s%s%s", apiUsername, timestamp, defaultBaseURL)
|
||||
|
||||
mac := hmac.New(sha256.New, []byte(apiKey))
|
||||
_, err = mac.Write([]byte(canonicalRequest))
|
||||
_, err := mac.Write([]byte(canonicalRequest))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -121,12 +121,7 @@ func (c *Client) do(req *http.Request, result any) error {
|
|||
|
||||
func (c *Client) sign(req *http.Request) error {
|
||||
if req.Header.Get("Date") == "" {
|
||||
location, err := time.LoadLocation("GMT")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
req.Header.Set("Date", time.Now().In(location).Format(time.RFC1123))
|
||||
req.Header.Set("Date", time.Now().UTC().Format(http.TimeFormat))
|
||||
}
|
||||
|
||||
if req.URL.Path == "" {
|
||||
|
|
|
@ -150,12 +150,7 @@ func (c *Client) DeleteRecord(ctx context.Context, domainName string, recordID i
|
|||
func (c *Client) do(req *http.Request, result any) error {
|
||||
req.Header.Set("Accept-Language", "en_us")
|
||||
|
||||
location, err := time.LoadLocation("GMT")
|
||||
if err != nil {
|
||||
return fmt.Errorf("time location: %w", err)
|
||||
}
|
||||
|
||||
err = c.sign(req, time.Now().In(location))
|
||||
err := c.sign(req, time.Now().UTC())
|
||||
if err != nil {
|
||||
return fmt.Errorf("signature: %w", err)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue