Class SubdomainTenantIdResolver
- Namespace
- Cratis.Arc.Tenancy
- Assembly
- Cratis.Arc.Core.dll
Represents an implementation of ITenantIdResolver that resolves the tenant ID from the request subdomain, with the configured HTTP header as fallback.
[IgnoreConvention]
public class SubdomainTenantIdResolver : ITenantIdResolver
- Inheritance
-
SubdomainTenantIdResolver
- Implements
- Inherited Members
- Extension Methods
Remarks
A host carries a tenant only when it is exactly one label in front of the configured
BaseDomain - acme.myapp.com resolves acme for the base domain
myapp.com. The base domain itself, a deeper host, an IP literal, an unrelated host and anything that is not
a valid DNS label fall back to HttpHeader. The number of labels in a host says nothing
about whether it carries a tenant, so it is never used to decide.
Constructors
SubdomainTenantIdResolver(IHttpRequestContextAccessor, IOptions<ArcOptions>)
Represents an implementation of ITenantIdResolver that resolves the tenant ID from the request subdomain, with the configured HTTP header as fallback.
public SubdomainTenantIdResolver(IHttpRequestContextAccessor httpRequestContextAccessor, IOptions<ArcOptions> options)
Parameters
httpRequestContextAccessorIHttpRequestContextAccessoroptionsIOptions<ArcOptions>The IOptions<TOptions>.
Remarks
A host carries a tenant only when it is exactly one label in front of the configured
BaseDomain - acme.myapp.com resolves acme for the base domain
myapp.com. The base domain itself, a deeper host, an IP literal, an unrelated host and anything that is not
a valid DNS label fall back to HttpHeader. The number of labels in a host says nothing
about whether it carries a tenant, so it is never used to decide.
Exceptions
- BaseDomainIsNotADomainName
Thrown when BaseDomain is not a domain name tenants can be resolved in front of.
Methods
Resolve()
Resolve the TenantId from the current context.
public string Resolve()
Returns
Exceptions
- BaseDomainIsNotADomainName
Thrown when BaseDomain is not a domain name tenants can be resolved in front of.