1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//! rok-tenant — Multi-tenancy for the rok ecosystem.
//!
//! Provides row-level tenant isolation via task-local tenant ID storage and a
//! Tower middleware that resolves the tenant per request.
//!
//! Two resolution strategies are supported:
//!
//! - **Shared table** — A `tenant_id` column is filtered automatically via a
//! global scope when `#[model(tenant_scoped)]` is applied.
//! - **Separate schemas** — Use [`TenantSource::Subdomain`] to route each
//! request to a dedicated PostgreSQL schema (integration with `rok-orm`
//! schema switching is handled by the ORM layer).
//!
//! # Quick start
//!
//! ```rust,ignore
//! use rok_tenant::{TenantLayer, TenantSource, current_tenant_id};
//!
//! // Extract tenant from X-Tenant-ID header
//! let app = Router::new()
//! .nest("/", routes())
//! .layer(TenantLayer::from_header("X-Tenant-ID"));
//!
//! // Or from the subdomain
//! let app = Router::new()
//! .nest("/", routes())
//! .layer(TenantLayer::from_subdomain());
//!
//! // Inside a handler or model method:
//! let tenant = current_tenant_id(); // → Option<i64>
//! ```
pub use current_tenant_id;
pub use ;
pub use TenantError;