minor cleanup
This commit is contained in:
@@ -90,11 +90,12 @@ func (c *SpotifyClient) GetPlaylist(playlistID string) (*SpotifyPlaylist, error)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
defer resp.Body.Close()
|
||||
|
||||
body, _ := io.ReadAll(resp.Body)
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return nil, fmt.Errorf("API error (%d): %s", resp.StatusCode, body)
|
||||
return nil, fmt.Errorf("status code: %d: %s", resp.StatusCode, body)
|
||||
}
|
||||
|
||||
var playlist SpotifyPlaylist
|
||||
@@ -115,6 +116,7 @@ func (c *SpotifyClient) renewToken() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
req.Header.Set("Authorization", "Basic "+creds)
|
||||
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||
|
||||
@@ -122,11 +124,12 @@ func (c *SpotifyClient) renewToken() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
defer resp.Body.Close()
|
||||
|
||||
body, _ := io.ReadAll(resp.Body)
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return fmt.Errorf("auth failed (%d): %s", resp.StatusCode, body)
|
||||
return fmt.Errorf("auth failed: %d: %s", resp.StatusCode, body)
|
||||
}
|
||||
|
||||
var token spotifyTokenResponse
|
||||
@@ -158,5 +161,6 @@ func (c *SpotifyClient) doOnce(req *http.Request) (*http.Response, error) {
|
||||
c.mu.Lock()
|
||||
req.Header.Set("Authorization", "Bearer "+c.token)
|
||||
c.mu.Unlock()
|
||||
|
||||
return c.httpClient.Do(req)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user