pub struct WithMiddleware<E, M>where
E: Endpoint,
M: Middleware,{ /* private fields */ }Expand description
A wrapper that combines an endpoint with middleware.
WithMiddleware allows you to compose an endpoint with middleware to add
cross-cutting concerns like logging, authentication, rate limiting, etc.
The middleware is executed first and can decide whether to call the endpoint
and how to process the response.
§Type Parameters
E- The endpoint type that implementsEndpointM- The middleware type that implementsMiddleware
Implementations§
Source§impl<E, M> WithMiddleware<E, M>where
E: Endpoint,
M: Middleware,
impl<E, M> WithMiddleware<E, M>where
E: Endpoint,
M: Middleware,
Sourcepub fn new(endpoint: E, middleware: M) -> WithMiddleware<E, M>
pub fn new(endpoint: E, middleware: M) -> WithMiddleware<E, M>
Creates a new endpoint that wraps the given endpoint with middleware.
When the resulting endpoint handles a request, the middleware will be executed first. The middleware can then decide whether to call the wrapped endpoint and how to process its response.
§Arguments
endpoint- The endpoint to wrapmiddleware- The middleware to apply
Trait Implementations§
Source§impl<E, M> Clone for WithMiddleware<E, M>
impl<E, M> Clone for WithMiddleware<E, M>
Source§fn clone(&self) -> WithMiddleware<E, M>
fn clone(&self) -> WithMiddleware<E, M>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<E, M> Debug for WithMiddleware<E, M>
impl<E, M> Debug for WithMiddleware<E, M>
Source§impl<E, M> Default for WithMiddleware<E, M>
impl<E, M> Default for WithMiddleware<E, M>
Source§fn default() -> WithMiddleware<E, M>
fn default() -> WithMiddleware<E, M>
Returns the “default value” for a type. Read more
Source§impl<E, M> Endpoint for WithMiddleware<E, M>where
E: Endpoint,
M: Middleware,
impl<E, M> Endpoint for WithMiddleware<E, M>where
E: Endpoint,
M: Middleware,
Source§type Error = MiddlewareError<<E as Endpoint>::Error, <M as Middleware>::Error>
type Error = MiddlewareError<<E as Endpoint>::Error, <M as Middleware>::Error>
The error type returned by this endpoint.
Source§impl<E, M> Hash for WithMiddleware<E, M>
impl<E, M> Hash for WithMiddleware<E, M>
Source§impl<E, M> Ord for WithMiddleware<E, M>
impl<E, M> Ord for WithMiddleware<E, M>
Source§fn cmp(&self, other: &WithMiddleware<E, M>) -> Ordering
fn cmp(&self, other: &WithMiddleware<E, M>) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<E, M> PartialEq for WithMiddleware<E, M>
impl<E, M> PartialEq for WithMiddleware<E, M>
Source§impl<E, M> PartialOrd for WithMiddleware<E, M>
impl<E, M> PartialOrd for WithMiddleware<E, M>
impl<E, M> Eq for WithMiddleware<E, M>
impl<E, M> StructuralPartialEq for WithMiddleware<E, M>where
E: Endpoint,
M: Middleware,
Auto Trait Implementations§
impl<E, M> Freeze for WithMiddleware<E, M>
impl<E, M> RefUnwindSafe for WithMiddleware<E, M>where
E: RefUnwindSafe,
M: RefUnwindSafe,
impl<E, M> Send for WithMiddleware<E, M>
impl<E, M> Sync for WithMiddleware<E, M>
impl<E, M> Unpin for WithMiddleware<E, M>
impl<E, M> UnwindSafe for WithMiddleware<E, M>where
E: UnwindSafe,
M: UnwindSafe,
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
Mutably borrows from an owned value. Read more