#[non_exhaustive]pub struct TenantConfig {
pub strategy: TenantStrategy,
pub header_name: String,
pub parameter_name: String,
pub domain_fallback: Option<String>,
}Expand description
Configuration settings for multitenancy extraction.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.strategy: TenantStrategyThe extraction strategy to be used.
header_name: StringThe name of the custom HTTP header (used only with TenantStrategy::Header).
parameter_name: StringThe name of the query parameter (used only with TenantStrategy::Parameter).
domain_fallback: Option<String>Fallback tenant ID to use when subdomain/header resolution fails or is absent.
Implementations§
Source§impl TenantConfig
impl TenantConfig
Sourcepub fn new(strategy: TenantStrategy) -> Self
pub fn new(strategy: TenantStrategy) -> Self
Creates a new TenantConfig with default values:
- Header Name: X-Tenant-ID
- Parameter Name: tenant_id
- Domain Fallback: None
Sourcepub fn with_header_name<S: Into<String>>(self, name: S) -> Self
pub fn with_header_name<S: Into<String>>(self, name: S) -> Self
Set a custom HTTP header name to extract the tenant ID from.
Sourcepub fn with_parameter_name<S: Into<String>>(self, name: S) -> Self
pub fn with_parameter_name<S: Into<String>>(self, name: S) -> Self
Set a custom Query Parameter name to extract the tenant ID from.
Sourcepub fn with_domain_fallback<S: Into<String>>(self, fallback: S) -> Self
pub fn with_domain_fallback<S: Into<String>>(self, fallback: S) -> Self
Set a fallback tenant ID when domain extraction fails in Subdomain strategy.
Trait Implementations§
Source§impl Clone for TenantConfig
impl Clone for TenantConfig
Auto Trait Implementations§
impl Freeze for TenantConfig
impl RefUnwindSafe for TenantConfig
impl Send for TenantConfig
impl Sync for TenantConfig
impl Unpin for TenantConfig
impl UnsafeUnpin for TenantConfig
impl UnwindSafe for TenantConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more