ctxutil

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 17, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package ctxutil provides utility functions for storing and retrieving request-scoped values in context.Context.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Permissions

func Permissions(ctx context.Context) ([]string, bool)

Permissions returns the permissions from the context claims.

func RequestID

func RequestID(ctx context.Context) (string, bool)

RequestID returns the request ID from the context.

func Roles

func Roles(ctx context.Context) ([]string, bool)

Roles returns the roles from the context claims.

func TenantID

func TenantID(ctx context.Context) (string, bool)

TenantID returns the tenant ID from the context claims.

func UserID

func UserID(ctx context.Context) (string, bool)

UserID returns the user ID from the context claims.

func WithClaims

func WithClaims(ctx context.Context, claims Claims) context.Context

WithClaims returns a new context with the claims set.

func WithRequestID

func WithRequestID(ctx context.Context, id string) context.Context

WithRequestID returns a new context with the request ID set.

Types

type Claims

type Claims struct {
	UserID      string
	TenantID    string
	Roles       []string
	Permissions []string
}

Claims holds JWT-related identity information.

func GetClaims

func GetClaims(ctx context.Context) (Claims, bool)

GetClaims returns the claims from the context.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL