Some checks failed
CI / Build & Test (push) Failing after 1m31s
- Add user management endpoints (list/create/get/update/delete) with pagination and search - Add dashboard stats endpoint with tenant/user/online counts and growth metrics - Add tenant resolver middleware for multi-tenant request scoping - Add i18n kernel with zh/en message files and AcceptLanguage middleware - Add WebSocket hub/handler for real-time communication - Add job scheduler kernel with cron support - Add plugin sandbox for isolated execution - Add storage kernel (local filesystem) - Add event bus kernel for pub/sub - Add cache kernel abstraction - Add database migration runner and version upgrade checker - Add rate limiting middleware with Redis backend - Add SQL migrations for rbac, audit_logs, settings, notifications, examples - Extend user repository with list/delete/count operations - Register all module routes with tenant resolver
44 lines
822 B
Go
44 lines
822 B
Go
package tenant
|
|
|
|
import "mengstack/internal/config"
|
|
|
|
type Resolver interface {
|
|
Resolve(headerValue, queryValue string) (string, bool)
|
|
IsMulti() bool
|
|
}
|
|
|
|
func NewResolver(cfg config.TenantConfig) Resolver {
|
|
if cfg.Mode == "single" {
|
|
return &singleResolver{defaultID: cfg.DefaultID}
|
|
}
|
|
return &multiResolver{}
|
|
}
|
|
|
|
type singleResolver struct {
|
|
defaultID string
|
|
}
|
|
|
|
func (r *singleResolver) Resolve(_, _ string) (string, bool) {
|
|
return r.defaultID, r.defaultID != ""
|
|
}
|
|
|
|
func (r *singleResolver) IsMulti() bool {
|
|
return false
|
|
}
|
|
|
|
type multiResolver struct{}
|
|
|
|
func (r *multiResolver) Resolve(headerValue, queryValue string) (string, bool) {
|
|
if headerValue != "" {
|
|
return headerValue, true
|
|
}
|
|
if queryValue != "" {
|
|
return queryValue, true
|
|
}
|
|
return "", false
|
|
}
|
|
|
|
func (r *multiResolver) IsMulti() bool {
|
|
return true
|
|
}
|