xcontext

package
v2.0.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2023 License: MIT Imports: 3 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

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