TTenantMiddleware Class
Middleware that extracts tenant information from incoming HTTP requests.
Remarks
This middleware supports multiple strategies for tenant identification:
- HTTP header (e.g., x-tenant-id)
- Query string parameter
- URL path segment
- Subdomain extraction
- User claim from authentication
- Domain mapping
The resolved tenant is stored in the request context and can be retrieved using Context.Item<ITenant>.
Syntax
Unit: Sparkle.Middleware.Tenant
TTenantMiddleware = class(THttpServerMiddleware, IHttpServerMiddleware);
Constants
| Name | Description |
|---|---|
| DefaultHeaderName | Default HTTP header name used for tenant identification. |
| DefaultQueryParam | Default query string parameter name used for tenant identification. |
Properties
| Name | Description |
|---|---|
| HeaderName | The name of the HTTP header to read the tenant ID from. |
| QueryParam | The name of the query string parameter to read the tenant ID from. |
| BasePath | The base path prefix used for path-based tenant extraction. |
| BaseDomain | The base domain used for subdomain-based tenant extraction. |
| UserClaim | The name of the user claim to read the tenant ID from. |
| RequireTenant | Indicates whether a tenant ID is required for all requests. |
| DomainMap | A mapping of domain names to tenant IDs. |