mirror of
https://git.sr.ht/~phw/scotty
synced 2025-04-30 05:37:05 +02:00
Added constants for app name and version, use custom user-agent
This commit is contained in:
parent
f6b4ea4a46
commit
46e6a667c8
10 changed files with 75 additions and 6 deletions
|
@ -30,6 +30,7 @@ import (
|
|||
|
||||
"github.com/go-resty/resty/v2"
|
||||
"go.uploadedlobster.com/scotty/internal/ratelimit"
|
||||
"go.uploadedlobster.com/scotty/internal/version"
|
||||
"golang.org/x/oauth2"
|
||||
)
|
||||
|
||||
|
@ -48,6 +49,7 @@ func NewClient(token oauth2.TokenSource) Client {
|
|||
client := resty.NewWithClient(httpClient)
|
||||
client.SetBaseURL(baseURL)
|
||||
client.SetHeader("Accept", "application/json")
|
||||
client.SetHeader("User-Agent", version.UserAgent())
|
||||
|
||||
// Handle rate limiting (see https://developer.spotify.com/documentation/web-api/concepts/rate-limits)
|
||||
ratelimit.EnableHTTPHeaderRateLimit(client, "Retry-After")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue