aboutsummaryrefslogtreecommitdiff
path: root/pkg/ext
diff options
context:
space:
mode:
authorGabriel Arakaki Giovanini <mail@gabrielgio.me>2023-08-19 16:50:04 +0200
committerGabriel Arakaki Giovanini <mail@gabrielgio.me>2023-08-19 16:50:04 +0200
commit2857052a38c9ad2c5946f6101bf7d37d63235df8 (patch)
tree8c80c37560336171b5b0e550a0244ebbcfc1e160 /pkg/ext
parent6531b1c0a720a63ee3127f9a09f14ba861838b01 (diff)
downloadlens-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.go10
-rw-r--r--pkg/ext/responses.go2
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",
})