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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//! Flat index of every Tower Layer modo ships.
//!
//! Wiring-site ergonomics: `use modo::middlewares as mw;` then
//! `.layer(mw::cors(cfg))`, `.layer(mw::role(extractor))`, `.layer(mw::Flash::new(cfg))`, etc.
//!
//! # Name shadowing with [`crate::prelude`]
//!
//! Some layer names in this module deliberately re-export a type under the
//! same name used by a factory in [`crate::prelude`]. For example,
//! [`crate::prelude::I18n`] is the factory ([`crate::i18n::I18n`]) while
//! [`I18n`] in this module is the Tower layer ([`crate::i18n::I18nLayer`]).
//! [`Flash`] has the same split ([`crate::flash::Flash`] vs
//! [`crate::flash::FlashLayer`]).
//!
//! A file that does both `use modo::prelude::*;` and
//! `use modo::middlewares::*;` at once will silently shadow one with the
//! other — whichever `use` came second wins, with no compiler warning. The
//! recommended convention is `use modo::middlewares as mw;` so layer names
//! sit behind the `mw::` prefix and never collide with prelude items.
//!
//! # Calling conventions
//!
//! Two calling conventions are exported, matching how the underlying
//! domain modules construct their layers:
//!
//! - **lower_case names are functions** — call them directly:
//! `mw::role(extractor)`, `mw::tenant(strategy, resolver)`,
//! `mw::cors(cors_cfg)`, `mw::csrf(csrf_cfg)`.
//! - **PascalCase names are `Layer` structs** — call `::new(...)`:
//! `mw::Jwt::new(cfg)`, `mw::ApiKey::new(store)`,
//! `mw::Flash::new(cookie_cfg)`, `mw::ClientIp::new(trusted_proxies)`.
//!
//! The split reflects upstream constructor design (some modules expose
//! free constructors, others only their `Layer` type). It avoids
//! inventing wrapper functions just for uniformity.
// Free constructor functions.
pub use cratemiddleware as role;
// NOTE: session layer constructor removed in v0.8 — SessionStore is now pub(crate);
// use modo::auth::session::layer directly within-crate, or via TestSession in tests.
pub use cratemiddleware as tenant;
// Layer structs — users call `::new(...)`.
pub use crateApiKeyLayer as ApiKey;
pub use crateJwtLayer as Jwt;
pub use crateFlashLayer as Flash;
pub use crateGeoLayer as Geo;
pub use crateI18nLayer as I18n;
pub use crateClientIpLayer as ClientIp;
pub use crateTemplateContextLayer as TemplateContext;
pub use crateTierLayer as Tier;
// Always-available middleware — free functions.
pub use crate;