pub struct TierLayer { /* private fields */ }Expand description
Tower middleware layer that resolves TierInfo and inserts it into
request extensions.
Apply with .layer() on the router. Guards (super::require_feature,
super::require_limit) are applied separately with .route_layer().
§Owner ID extraction
The extractor closure reads from &Parts (populated by upstream middleware)
and returns Some(owner_id) or None.
§Default tier
When the extractor returns None and a default is set via
with_default, the default TierInfo is inserted.
Otherwise, no TierInfo is inserted and the inner service is called
directly — downstream guards handle the absence.
Implementations§
Source§impl TierLayer
impl TierLayer
Sourcepub fn new<F>(resolver: TierResolver, extractor: F) -> Self
pub fn new<F>(resolver: TierResolver, extractor: F) -> Self
Create a new tier layer.
extractor is a sync closure that returns the owner ID from request
parts, or None if no owner context is available.
Sourcepub fn with_default(self, default: TierInfo) -> Self
pub fn with_default(self, default: TierInfo) -> Self
When the extractor returns None, inject this TierInfo instead of
skipping.