defer body close after encoding json

This commit is contained in:
Elizabeth 2024-04-02 14:53:50 -06:00
parent d7843d18d0
commit 657be66948
Signed by: simponic
GPG Key ID: 2909B9A7FF6213EE
1 changed files with 3 additions and 1 deletions

View File

@ -259,11 +259,13 @@ func getOauthUser(dbConn *sql.DB, client *http.Client, uri string) (*database.Us
}
func createUserFromResponse(response *http.Response) (*database.User, error) {
defer response.Body.Close()
user := &database.User{
CreatedAt: time.Now(),
}
err := json.NewDecoder(response.Body).Decode(user)
defer response.Body.Close()
if err != nil {
log.Println(err)
return nil, err