Clean up comments and defer response body closing
This commit is contained in:
parent
48bf0df6d4
commit
d38fef3be2
2 changed files with 2 additions and 5 deletions
|
@ -10,7 +10,7 @@ import (
|
|||
)
|
||||
|
||||
// Pagination helper middleware
|
||||
// This just checks and inserts some default pagination values
|
||||
// This just checks and inserts some default pagination values into the request context
|
||||
func paginator() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
queryPage := c.DefaultQuery("page", "1")
|
||||
|
|
5
utils.go
5
utils.go
|
@ -38,7 +38,6 @@ func getSpotifyArtistData(artistID string, spotifyAuthToken string) (SpotifyResp
|
|||
}
|
||||
req.Header.Add("Authorization", spotifyAuthToken)
|
||||
|
||||
// Send off request
|
||||
resp, err := http.DefaultClient.Do(req)
|
||||
if err != nil {
|
||||
respErr := &ResponseError{
|
||||
|
@ -53,6 +52,7 @@ func getSpotifyArtistData(artistID string, spotifyAuthToken string) (SpotifyResp
|
|||
}
|
||||
return SpotifyResponse{}, respErr
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
var spotifyResponse SpotifyResponse
|
||||
err = json.NewDecoder(resp.Body).Decode(&spotifyResponse)
|
||||
|
@ -64,9 +64,6 @@ func getSpotifyArtistData(artistID string, spotifyAuthToken string) (SpotifyResp
|
|||
return SpotifyResponse{}, respErr
|
||||
}
|
||||
|
||||
// Close this immediately since it's unused now
|
||||
resp.Body.Close()
|
||||
|
||||
// After all the above checks we assume this response is populated
|
||||
// If errors arise we can do extra validation here
|
||||
return spotifyResponse, nil
|
||||
|
|
Loading…
Add table
Reference in a new issue