summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorJulien Dessaux2024-11-15 23:48:35 +0100
committerJulien Dessaux2024-11-15 23:48:35 +0100
commit478f42f8a9f070cef9e8c0b81dc7bd4c24bacde8 (patch)
tree2140b7b89ddf04ae3d9b149bf6d51061769178c5 /pkg
parentfeat(tfstated): implement HTTP basic auth (diff)
downloadtfstated-478f42f8a9f070cef9e8c0b81dc7bd4c24bacde8.tar.gz
tfstated-478f42f8a9f070cef9e8c0b81dc7bd4c24bacde8.tar.bz2
tfstated-478f42f8a9f070cef9e8c0b81dc7bd4c24bacde8.zip
chore(tfstated): use a struct{} as context.Context key
Diffstat (limited to 'pkg')
-rw-r--r--pkg/basic_auth/middleware.go3
-rw-r--r--pkg/model/account.go2
2 files changed, 4 insertions, 1 deletions
diff --git a/pkg/basic_auth/middleware.go b/pkg/basic_auth/middleware.go
index 108124f..94cac56 100644
--- a/pkg/basic_auth/middleware.go
+++ b/pkg/basic_auth/middleware.go
@@ -6,6 +6,7 @@ import (
"time"
"git.adyxax.org/adyxax/tfstated/pkg/database"
+ "git.adyxax.org/adyxax/tfstated/pkg/model"
)
func Middleware(db *database.DB) func(http.Handler) http.Handler {
@@ -32,7 +33,7 @@ func Middleware(db *database.DB) func(http.Handler) http.Handler {
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
return
}
- ctx := context.WithValue(r.Context(), "account", account)
+ ctx := context.WithValue(r.Context(), model.AccountContextKey{}, account)
next.ServeHTTP(w, r.WithContext(ctx))
})
}
diff --git a/pkg/model/account.go b/pkg/model/account.go
index cbb6407..86032b8 100644
--- a/pkg/model/account.go
+++ b/pkg/model/account.go
@@ -2,6 +2,8 @@ package model
import "time"
+type AccountContextKey struct{}
+
type Account struct {
Id int
Username string