Documentation
¶
Index ¶
- func Claims[T any](ctx context.Context) (T, bool)
- func RequestID(ctx context.Context) string
- func Scopes(ctx context.Context) []string
- func SubjectID(ctx context.Context) string
- func TenantID(ctx context.Context) string
- func WithClaims[T any](ctx context.Context, claims T) context.Context
- func WithRequestID(ctx context.Context, requestID string) context.Context
- func WithScopes(ctx context.Context, scopes []string) context.Context
- func WithSubjectID(ctx context.Context, subjectID string) context.Context
- func WithTenantID(ctx context.Context, tenantID string) context.Context
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Claims ¶
Claims loads claims of type T from ctx. Returns (zero, false) if not present or type mismatch.
func Scopes ¶
Scopes returns the scopes stored in ctx.
The returned slice is a copy to prevent caller mutation. If not set, returns nil.
func WithClaims ¶
WithClaims stores arbitrary claims in context. Use sparingly. Defensive behavior: if ctx is nil, it is treated as context.Background().
func WithRequestID ¶
WithRequestID returns a derived context carrying request_id.
Defensive behavior: if ctx is nil, it is treated as context.Background(). Empty requestID is ignored (ctx returned unchanged).
func WithScopes ¶
WithScopes returns a derived context carrying scopes ([]string).
The slice is copied on write to prevent caller mutation. Defensive behavior: if ctx is nil, it is treated as context.Background(). Empty scopes is ignored (ctx returned unchanged).
func WithSubjectID ¶
WithSubjectID returns a derived context carrying subject_id (sub).
Defensive behavior: if ctx is nil, it is treated as context.Background(). Empty subjectID is ignored (ctx returned unchanged).
Types ¶
This section is empty.