More resilient HTTP requests

Fixed rate limit check for ListenBrainz and Funkwhale. Also retry always
on server side errors.
This commit is contained in:
Philipp Wolfer 2023-11-15 08:40:55 +01:00
parent 240351dc3e
commit 4e9f50b6b6
No known key found for this signature in database
GPG key ID: 8FDF744D4919943B
3 changed files with 28 additions and 12 deletions

View file

@ -34,15 +34,14 @@ type Client struct {
}
func NewClient(serverUrl string, token string) Client {
resty := resty.New()
resty.SetBaseURL(serverUrl)
resty.SetHeader("Accept", "application/json")
client := Client{
HttpClient: resty,
client := resty.New()
client.SetBaseURL(serverUrl)
client.SetHeader("Accept", "application/json")
client.SetRetryCount(5)
return Client{
HttpClient: client,
token: token,
}
return client
}
func (c Client) GetScrobbles(page int, perPage int) (result GetScrobblesResult, err error) {