xcontext

package
v0.48.1 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2023 License: MIT Imports: 3 Imported by: 1

Documentation

Index

Constants

View Source
const (
	UserCtxKey    = "x-user"
	TenantCtxKey  = "x-tenant"
	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 added in v0.13.0

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