Skip to content

Commit

Permalink
Merge pull request #48 from elijahmorg/feature/setToken
Browse files Browse the repository at this point in the history
Re-add ability to set access token independently
  • Loading branch information
tranhoangvuit authored May 21, 2024
2 parents f71cf28 + fa7d2de commit 9413d68
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

var (
version = "v0.1.0"
version = "v0.1.1"
)

type Client struct {
Expand Down Expand Up @@ -82,11 +82,15 @@ func (c *Client) Ping() bool {
return true
}

// TokenAuth sets authorization headers for subsequent requests.
func (c *Client) TokenAuth(token string) *Client {
c.Transport.header.Set("Authorization", "Bearer "+token)
c.Transport.header.Set("apikey", token)
// SetApiKey sets api key header for subsequent requests.
func (c *Client) SetApiKey(apiKey string) *Client {
c.Transport.header.Set("apikey", apiKey)
return c
}

// SetAuthToken sets authorization header for subsequent requests.
func (c *Client) SetAuthToken(authToken string) *Client {
c.Transport.header.Set("Authorization", "Bearer "+authToken)
return c
}

Expand Down

0 comments on commit 9413d68

Please sign in to comment.