tenant

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package tenant provides multi-tenant scoping middleware.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorHandler

type ErrorHandler func(w http.ResponseWriter, r *http.Request, err error)

ErrorHandler handles authorization errors from the tenant middleware.

type Middleware

type Middleware struct {
	// contains filtered or unexported fields
}

Middleware enforces tenant scoping and stores the tenant in context.

func New

func New(opts Options) (*Middleware, error)

New creates a tenant scoping middleware.

func (*Middleware) Handler

func (m *Middleware) Handler(next http.Handler) http.Handler

Handler wraps the next handler with tenant checks.

type Options

type Options struct {
	Optional          bool
	HeaderName        string
	URLParam          string
	URLParamExtractor ports.URLParamExtractor
	TenantFromContext TenantFromContext
	ErrorHandler      ErrorHandler
}

Options configures tenant scoping.

type TenantFromContext

type TenantFromContext func(ctx context.Context) (string, bool)

TenantFromContext extracts a tenant identifier from context.

Jump to

Keyboard shortcuts

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