refactoring of code

This commit is contained in:
Jonas Kaninda
2024-11-17 03:56:47 +01:00
parent 858deb6b72
commit 9dc2dfcbb2
3 changed files with 26 additions and 19 deletions

View File

@@ -19,6 +19,7 @@ import (
"github.com/jkaninda/goma-gateway/pkg/logger"
"github.com/jkaninda/goma-gateway/util"
"golang.org/x/oauth2"
"io"
"net/http"
"time"
)
@@ -72,7 +73,12 @@ func (oauth *OauthRulerMiddleware) getUserInfo(token *oauth2.Token) (UserInfo, e
if err != nil {
return UserInfo{}, err
}
defer resp.Body.Close()
defer func(Body io.ReadCloser) {
err := Body.Close()
if err != nil {
}
}(resp.Body)
// Parse the user info
var userInfo UserInfo