Skip to content

Commit

Permalink
Merge branch 'master' into patch-6
Browse files Browse the repository at this point in the history
  • Loading branch information
moredure authored Apr 2, 2022
2 parents 923458b + f5dc865 commit ad06e05
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func (c *Client) PushWithContext(ctx Context, n *Notification) (*Response, error
}

url := fmt.Sprintf("%v/3/device/%v", c.Host, n.DeviceToken)
req, err := http.NewRequestWithContext(ctx, "POST", url, bytes.NewReader(payload))
req, err := http.NewRequest(http.MethodPost, url, bytes.NewReader(payload))
if err != nil {
return nil, err
}
Expand Down
8 changes: 4 additions & 4 deletions notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,12 @@ type Notification struct {

// MarshalJSON converts the notification payload to JSON.
func (n *Notification) MarshalJSON() ([]byte, error) {
switch n.Payload.(type) {
switch payload := n.Payload.(type) {
case string:
return []byte(n.Payload.(string)), nil
return []byte(payload), nil
case []byte:
return n.Payload.([]byte), nil
return payload, nil
default:
return json.Marshal(n.Payload)
return json.Marshal(payload)
}
}
6 changes: 2 additions & 4 deletions token/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,10 @@ func AuthKeyFromBytes(bytes []byte) (*ecdsa.PrivateKey, error) {
if err != nil {
return nil, err
}
switch pk := key.(type) {
case *ecdsa.PrivateKey:
if pk, ok := key.(*ecdsa.PrivateKey); ok {
return pk, nil
default:
return nil, ErrAuthKeyNotECDSA
}
return nil, ErrAuthKeyNotECDSA
}

// GenerateIfExpired checks to see if the token is about to expire and
Expand Down

0 comments on commit ad06e05

Please sign in to comment.