Documentation ¶
Index ¶
Constants ¶
View Source
const (
// XTenantHeader is the header key for the tenant
XTenantHeader = "X-Tenant"
)
Variables ¶
View Source
var ( // DefaultSkipper represents the default skipper DefaultSkipper = func(r *http.Request) bool { return false } // DefaultTenantGetters represents the default tenant getters DefaultTenantGetters = []func(r *http.Request) (string, error){ DefaultTenantFromSubdomain, DefaultTenantFromHeader, } )
View Source
var ( // NetHTTPTenantKey is the key that holds the tenant in the request context NetHTTPTenantKey = multitenancy_ctx.NetHTTPTenantKey // EchoTenantKey is the key that holds the tenant in the echo context EchoTenantKey = multitenancy_ctx.EchoTenantKey )
View Source
var ( // ErrTenantInvalid represents an error when the tenant is invalid or not found ErrTenantInvalid = fmt.Errorf("invalid tenant or tenant not found") // ErrDBInvalid represents an error when the database connection is invalid ErrDBInvalid = gorm.ErrInvalidDB )
Functions ¶
func DefaultTenantFromHeader ¶
DefaultTenantFromHeader retrieves the tenant from the request header
Types ¶
type WithTenantConfig ¶
type WithTenantConfig struct { DB *gorm.DB // DB is the database connection Skipper func(r *http.Request) bool // Skipper defines a function to skip middleware TenantGetters []func(r *http.Request) (string, error) // TenantGetters gets the tenant from the request; overrides the default getter }
WithTenantConfig represents the config for the tenant middleware
Click to show internal directories.
Click to hide internal directories.