Improved logging with zap
This commit is contained in:
@@ -5,13 +5,15 @@ import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"io"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
type GiteaOAuth2Handler struct {
|
||||
cfg *config.Config
|
||||
logger *zap.Logger
|
||||
}
|
||||
|
||||
func NewGiteaOauth2Token(cfg *config.Config) *GiteaOAuth2Handler {
|
||||
@@ -24,7 +26,7 @@ func (g *GiteaOAuth2Handler) GetGiteaLoginURL(redirectHost string) (string, erro
|
||||
}
|
||||
|
||||
if redirectHost == "" {
|
||||
slog.Error("Redirect host not provided")
|
||||
g.logger.Error("Redirect host not provided")
|
||||
return "", nil
|
||||
}
|
||||
|
||||
@@ -35,7 +37,7 @@ func (g *GiteaOAuth2Handler) GetGiteaLoginURL(redirectHost string) (string, erro
|
||||
func (g *GiteaOAuth2Handler) GetGiteaUserEmailByCode(code string) (string, error) {
|
||||
|
||||
if g.cfg.GiteaOauthInstance == "" {
|
||||
slog.Error("Instance URL not provided")
|
||||
g.logger.Error("Instance URL not provided")
|
||||
return "", nil
|
||||
}
|
||||
// No need to verify since we are accesing the gitea once and only for the email
|
||||
@@ -45,7 +47,7 @@ func (g *GiteaOAuth2Handler) GetGiteaUserEmailByCode(code string) (string, error
|
||||
}
|
||||
|
||||
userInfoUrl := g.cfg.GiteaOauthInstance + "/login/oauth/userinfo"
|
||||
slog.Info(userInfoUrl)
|
||||
g.logger.Info(userInfoUrl)
|
||||
req, err := http.NewRequest("POST", userInfoUrl, nil)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
||||
Reference in New Issue
Block a user