pub struct MiddlewareScope { /* private fields */ }Expand description
Selects the requests one registered middleware layer observes.
An empty scope matches every request, which is what
HttpApp::with_middleware registers. Path prefixes and operation
predicates combine as AND between the two categories and OR inside one
category.
The selected operation is unknown before routing, so a scope that declares
an operation predicate never matches HttpMiddleware::on_request; that
layer sees HttpMiddleware::on_operation and
HttpMiddleware::on_response instead. A layer whose scope does not match
is also not counted by the security guard, so a scoped verifier cannot
silently authorize an operation outside its subtree.
Implementations§
Source§impl MiddlewareScope
impl MiddlewareScope
Sourcepub fn with_prefix(self, prefix: &str) -> Self
pub fn with_prefix(self, prefix: &str) -> Self
Adds an accepted path prefix, matched on segment boundaries.
/ingest matches /ingest and /ingest/events, never /ingested.
Sourcepub fn with_operation(self, operation_id: &str) -> Self
pub fn with_operation(self, operation_id: &str) -> Self
Adds one accepted operation id.
Sourcepub fn with_operation_prefix(self, prefix: &str) -> Self
pub fn with_operation_prefix(self, prefix: &str) -> Self
Adds an accepted operation id prefix, for id namespaces such as
ingest..
Sourcepub fn with_operation_filter<Filter>(self, filter: Filter) -> Self
pub fn with_operation_filter<Filter>(self, filter: Filter) -> Self
Adds an operation id predicate for a selection the other constraints cannot express.
Sourcepub fn matches_request(&self, path: &str) -> bool
pub fn matches_request(&self, path: &str) -> bool
Matches before routing, when only the request path is known.
Sourcepub fn matches_operation(&self, path: &str, operation_id: &str) -> bool
pub fn matches_operation(&self, path: &str, operation_id: &str) -> bool
Matches after routing, when the selected operation is known.
Trait Implementations§
Source§impl Clone for MiddlewareScope
impl Clone for MiddlewareScope
Source§fn clone(&self) -> MiddlewareScope
fn clone(&self) -> MiddlewareScope
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more