Added constants for app name and version, use custom user-agent

This commit is contained in:
Philipp Wolfer 2023-11-24 08:58:31 +01:00
parent f6b4ea4a46
commit 46e6a667c8
No known key found for this signature in database
GPG key ID: 8FDF744D4919943B
10 changed files with 75 additions and 6 deletions

View file

@ -27,6 +27,7 @@ import (
"github.com/go-resty/resty/v2"
"go.uploadedlobster.com/scotty/internal/ratelimit"
"go.uploadedlobster.com/scotty/internal/version"
)
const MaxItemsPerGet = 50
@ -42,6 +43,7 @@ func NewClient(serverUrl string, token string) Client {
client.SetAuthScheme("Bearer")
client.SetAuthToken(token)
client.SetHeader("Accept", "application/json")
client.SetHeader("User-Agent", version.UserAgent())
// Handle rate limiting (see https://docs.funkwhale.audio/developer/api/rate-limit.html)
ratelimit.EnableHTTPHeaderRateLimit(client, "Retry-After")