We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
contextKey
authKey
1 parent 0b22ff8 commit dfb249dCopy full SHA for dfb249d
server/auth/authorizer/context.go
@@ -4,9 +4,9 @@ import (
4
"context"
5
)
6
7
-type contextKey string
+type authKey struct{}
8
9
-const contextKeyAuthorizerID = contextKey("authorizer")
+var authContextKey = authKey{}
10
11
type Data[I UID] struct {
12
UID I `json:"uid"`
@@ -15,11 +15,11 @@ type Data[I UID] struct {
15
}
16
17
func WithAuthData[I UID](ctx context.Context, data Data[I]) context.Context {
18
- return context.WithValue(ctx, contextKeyAuthorizerID, data)
+ return context.WithValue(ctx, authContextKey, data)
19
20
21
func GetAuthData[I UID](ctx context.Context) (Data[I], bool) {
22
- raw := ctx.Value(contextKeyAuthorizerID)
+ raw := ctx.Value(authContextKey)
23
if raw == nil {
24
return Data[I]{}, false
25
0 commit comments