This commit is contained in:
delete 2026-06-10 20:51:17 +03:00
commit b15b95781c
108 changed files with 14802 additions and 0 deletions

View file

@ -0,0 +1,32 @@
package apikeys
import (
"context"
"update_server/internal/db"
)
type contextKey string
const requestContextKey contextKey = "api-key"
type AuthState struct {
APIKey db.APIKey
}
func NewContext(ctx context.Context, state *AuthState) context.Context {
if state == nil {
return ctx
}
return context.WithValue(ctx, requestContextKey, *state)
}
func FromContext(ctx context.Context) (*AuthState, bool) {
state, ok := ctx.Value(requestContextKey).(AuthState)
if !ok {
return nil, false
}
return &state, true
}