tenant

package
v0.35.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JoinTenantIDs

func JoinTenantIDs(tenantIDs []string) string

func TenantID

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

TenantID returns exactly a single tenant ID from the context. It should be used when a certain endpoint should only support exactly a single tenant ID. It returns an error user.ErrNoOrgID if there is no tenant ID supplied or user.ErrTooManyOrgIDs if there are multiple tenant IDs present.

ignore stutter warning

func TenantIDs

func TenantIDs(ctx context.Context) ([]string, error)

TenantIDs returns all tenant IDs from the context. It should return normalized list of ordered and distinct tenant IDs (as produced by NormalizeTenantIDs).

ignore stutter warning

Types

type Resolver

type Resolver interface {
	// TenantID returns exactly a single tenant ID from the context. It should be
	// used when a certain endpoint should only support exactly a single
	// tenant ID. It returns an error user.ErrNoOrgID if there is no tenant ID
	// supplied or user.ErrTooManyOrgIDs if there are multiple tenant IDs present.
	TenantID(context.Context) (string, error)

	// TenantIDs returns all tenant IDs from the context. It should return
	// normalized list of ordered and distinct tenant IDs (as produced by
	// NormalizeTenantIDs).
	TenantIDs(context.Context) ([]string, error)
}

type SingleResolver

type SingleResolver struct {
}

func NewSingleResolver

func NewSingleResolver() *SingleResolver

NewSingleResolver creates a tenant resolver, which restricts all requests to be using a single tenant only. This allows a wider set of characters to be used within the tenant ID and should not impose a breaking change.

func (*SingleResolver) TenantID

func (t *SingleResolver) TenantID(ctx context.Context) (string, error)

func (*SingleResolver) TenantIDs

func (t *SingleResolver) TenantIDs(ctx context.Context) ([]string, error)

Jump to

Keyboard shortcuts

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