SpotifyGo/spotifygo.go
2021-11-17 16:40:26 +01:00

48 lines
854 B
Go

package SpotifyGo
import (
"net/http"
"strconv"
"time"
)
const (
defaultRetryDuration = 5
)
type SpotifyClient struct {
http *http.Client
shouldRetry bool
authenticated bool
}
func CreateClient(retry bool) *SpotifyClient {
// Create new spotify client
var client SpotifyClient
// Settings
client.http = &http.Client{}
client.shouldRetry = retry
client.authenticated = false
return &client
}
func (client SpotifyClient) executeRequest(req *http.Request) (interface{}, error) {
return nil, nil
}
func retryDuration(response *http.Response) time.Duration {
raw := response.Header.Get("Retry-After")
if raw == "" {
return time.Second * defaultRetryDuration
}
seconds, err := strconv.ParseInt(raw, 10, 32)
if err != nil {
return time.Second * defaultRetryDuration
}
return time.Duration(seconds) * time.Second
}