Files
nessi 3289da24af refactor: update module path from github.com/nexavpn/nexavpn/backend to nexavpn/backend
Update go.mod module declaration and all internal imports across the backend codebase to use simplified nexavpn/backend path instead of full GitHub URL.
2026-03-15 16:42:25 +01:00

31 lines
612 B
Go

package requestctx
import (
"context"
"github.com/google/uuid"
"nexavpn/backend/internal/identity"
)
type contextKey string
const claimsKey contextKey = "claims"
func WithClaims(ctx context.Context, claims identity.Claims) context.Context {
return context.WithValue(ctx, claimsKey, claims)
}
func ClaimsFromContext(ctx context.Context) (identity.Claims, bool) {
claims, ok := ctx.Value(claimsKey).(identity.Claims)
return claims, ok
}
func MustUserID(ctx context.Context) (uuid.UUID, bool) {
claims, ok := ClaimsFromContext(ctx)
if !ok {
return uuid.Nil, false
}
return claims.UserID, true
}