diff options
author | Gabriel Arakaki Giovanini <mail@gabrielgio.me> | 2023-08-19 16:50:04 +0200 |
---|---|---|
committer | Gabriel Arakaki Giovanini <mail@gabrielgio.me> | 2023-08-19 16:50:04 +0200 |
commit | 2857052a38c9ad2c5946f6101bf7d37d63235df8 (patch) | |
tree | 8c80c37560336171b5b0e550a0244ebbcfc1e160 /pkg/ext | |
parent | 6531b1c0a720a63ee3127f9a09f14ba861838b01 (diff) | |
download | lens-2857052a38c9ad2c5946f6101bf7d37d63235df8.tar.gz lens-2857052a38c9ad2c5946f6101bf7d37d63235df8.tar.bz2 lens-2857052a38c9ad2c5946f6101bf7d37d63235df8.zip |
fix: Fix various linting error
Diffstat (limited to 'pkg/ext')
-rw-r--r-- | pkg/ext/middleware.go | 10 | ||||
-rw-r--r-- | pkg/ext/responses.go | 2 |
2 files changed, 6 insertions, 6 deletions
diff --git a/pkg/ext/middleware.go b/pkg/ext/middleware.go index fe2d185..2cf70cf 100644 --- a/pkg/ext/middleware.go +++ b/pkg/ext/middleware.go @@ -56,7 +56,7 @@ func NewAuthMiddleware(key []byte, log *logrus.Entry) *AuthMiddleware { func (a *AuthMiddleware) LoggedIn(next http.HandlerFunc) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - path := string(r.URL.Path) + path := r.URL.Path if path == "/login" || path == "/initial" { next(w, r) return @@ -82,7 +82,7 @@ func (a *AuthMiddleware) LoggedIn(next http.HandlerFunc) http.HandlerFunc { http.Redirect(w, r, redirectLogin, http.StatusTemporaryRedirect) return } - r = r.WithContext(context.WithValue(r.Context(), "token", token)) + r = r.WithContext(context.WithValue(r.Context(), service.TokenKey, token)) a.entry. WithField("userID", token.UserID). WithField("username", token.Username). @@ -91,8 +91,8 @@ func (a *AuthMiddleware) LoggedIn(next http.HandlerFunc) http.HandlerFunc { } } -func GetTokenFromCtx(w http.ResponseWriter, r *http.Request) *service.Token { - tokenValue := r.Context().Value("token") +func GetTokenFromCtx(r *http.Request) *service.Token { + tokenValue := r.Context().Value(service.TokenKey) if token, ok := tokenValue.(*service.Token); ok { return token } @@ -112,7 +112,7 @@ func NewInitialSetupMiddleware(userRepository repository.UserRepository) *Initia func (i *InitialSetupMiddleware) Check(next http.HandlerFunc) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { // if user has been set to context it is logged in already - token := GetTokenFromCtx(w, r) + token := GetTokenFromCtx(r) if token == nil { next(w, r) return diff --git a/pkg/ext/responses.go b/pkg/ext/responses.go index ba58dd5..34e5f27 100644 --- a/pkg/ext/responses.go +++ b/pkg/ext/responses.go @@ -7,7 +7,7 @@ import ( "git.sr.ht/~gabrielgio/img/templates" ) -func NotFound(w http.ResponseWriter, r *http.Request) { +func NotFound(w http.ResponseWriter) { templates.WritePageTemplate(w, &templates.ErrorPage{ Err: "Not Found", }) |