xcontext

package
v2.0.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// JwtCtxKey is the key used to store the JWT (raw) string in the context
	JwtCtxKey = "as-jwt-token"
	// UserCtxKey is the key used to store the user in the context
	UserCtxKey = "x-user"
	// ImpersonatingUserKeyName is the key used to store the impersonating (real)
	// user in the context
	ImpersonatingUserKeyName = "x-real-user"
	// TenantCtxKey is the key used to store the tenant in the context. If present
	// it will be used in case the user is not present.
	TenantCtxKey = "x-tenant"

	// DefaultTenant is the tenant to use if no tenant is found in the context
	DefaultTenant = "default"
)

Variables

This section is empty.

Functions

func Tenant

func Tenant(ctx context.Context) (tenant string, found bool)

Tenant returns the tenant from the context if it exists.

func TenantOrDefault

func TenantOrDefault(ctx context.Context) string

TenantOrDefault returns the tenant from the context if it exists or the default value.

func User

func User(ctx context.Context) (xuser.User, error)

User returns the user from the context if it exists. If the user does not exist, returns an unauthorized error.

func WithUser

func WithUser(ctx context.Context, user xuser.User) context.Context

WithUser returns a new context with the user set.

Types

This section is empty.

Jump to

Keyboard shortcuts

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