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.
Trait Implementations§
Source§impl Middleware for ExcludeMiddleware
impl Middleware for ExcludeMiddleware
Auto Trait Implementations§
impl Freeze for ExcludeMiddleware
impl !RefUnwindSafe for ExcludeMiddleware
impl Send for ExcludeMiddleware
impl Sync for ExcludeMiddleware
impl Unpin for ExcludeMiddleware
impl UnsafeUnpin for ExcludeMiddleware
impl !UnwindSafe for ExcludeMiddleware
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more