pub struct ExcludeMiddleware { /* private fields */ }Expand description
Middleware wrapper that excludes specific URL paths from execution.
When a request matches an excluded path, the middleware is skipped and the request passes directly to the next handler in the chain.
Path matching follows Django URL conventions:
- Paths ending with
/are treated as prefix matches (e.g.,"/api/auth/"excludes"/api/auth/login","/api/auth/register") - Paths without trailing
/require an exact match (e.g.,"/health"excludes only"/health", not"/health/check")
This struct is typically not used directly. Instead, use the
exclude methods on the ServerRouter or UnifiedRouter types
from the reinhardt_urls::routers module for declarative
route exclusion at the router level.
§Examples
use reinhardt_http::middleware::ExcludeMiddleware;
use reinhardt_http::{Middleware, Request};
use std::sync::Arc;
let inner: Arc<dyn Middleware> = Arc::new(MyMiddleware);
let excluded = ExcludeMiddleware::new(inner)
.add_exclusion("/api/auth/") // prefix match
.add_exclusion("/health"); // exact matchImplementations§
Source§impl ExcludeMiddleware
impl ExcludeMiddleware
Sourcepub fn new(inner: Arc<dyn Middleware>) -> Self
pub fn new(inner: Arc<dyn Middleware>) -> Self
Creates a new ExcludeMiddleware wrapping the given middleware.
Sourcepub fn add_exclusion(self, pattern: &str) -> Self
pub fn add_exclusion(self, pattern: &str) -> Self
Adds an exclusion pattern (builder pattern, consumes self).
Paths ending with / are prefix matches; others are exact matches.
Sourcepub fn add_exclusion_mut(&mut self, pattern: &str)
pub fn add_exclusion_mut(&mut self, pattern: &str)
Adds an exclusion pattern (mutable reference).
Paths ending with / are prefix matches; others are exact matches.