identity

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2025 License: Apache-2.0 Imports: 5 Imported by: 8

Documentation

Index

Constants

View Source
const (
	TenantContextKey = "_woocoos/knockout/tenant_id"
	TenantHeaderKey  = "X-Tenant-ID"
)

Variables

View Source
var (
	ErrInvalidUserID = errors.New("invalid user")
	ErrMisTenantID   = errors.New("miss tenant id")
)

Functions

func TenantIDFromContext

func TenantIDFromContext(ctx context.Context) (id int, err error)

TenantIDFromContext returns the tenant id from context.

func TenantIDLoadFromContext

func TenantIDLoadFromContext(ctx context.Context) (id int, ok bool)

TenantIDLoadFromContext returns the tenant id from context. tenant id has set by int format, this function simply returns the value.

func UserIDFromContext

func UserIDFromContext(ctx context.Context) (int, error)

UserIDFromContext returns the user id from context.

func UserIDFromContextAsInt

func UserIDFromContextAsInt(ctx context.Context) (int, error)

UserIDFromContextAsInt returns the user id from context, the context don't save Int UserID in context, we need transfer it from string to int

func WithTenantID

func WithTenantID(parent context.Context, id int) context.Context

WithTenantID returns a new context with tenant id

Types

This section is empty.

Jump to

Keyboard shortcuts

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