pub struct TowerMiddleware<S> { /* private fields */ }Expand description
Churust Middleware wrapping a tower Layer applied over NextService.
Build one with TowerMiddleware::new and install it like any other
plugin. The layered service is constructed once, so layer state persists
across requests.
Implementations§
Source§impl<S> TowerMiddleware<S>
impl<S> TowerMiddleware<S>
Sourcepub fn new<L>(layer: L) -> Selfwhere
L: Layer<NextService, Service = S>,
pub fn new<L>(layer: L) -> Selfwhere
L: Layer<NextService, Service = S>,
Apply layer over the Churust pipeline.
Runs in Phase::Plugins; use TowerMiddleware::in_phase to place
it earlier or later in the onion.
Sourcepub fn in_phase(self, phase: Phase) -> Self
pub fn in_phase(self, phase: Phase) -> Self
Run this layer in a specific Phase rather than Phase::Plugins.
Trait Implementations§
Source§impl<S, ResBody> Middleware for TowerMiddleware<S>
impl<S, ResBody> Middleware for TowerMiddleware<S>
Source§fn handle<'life0, 'async_trait>(
&'life0 self,
call: Call,
next: Next,
) -> Pin<Box<dyn Future<Output = Response> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn handle<'life0, 'async_trait>(
&'life0 self,
call: Call,
next: Next,
) -> Pin<Box<dyn Future<Output = Response> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Handle the call: optionally inspect/modify it, call
next.run(call) to
proceed, and return the (possibly post-processed) response.Source§impl<S, ResBody> Plugin for TowerMiddleware<S>
impl<S, ResBody> Plugin for TowerMiddleware<S>
Source§fn install(self: Box<Self>, app: &mut AppBuilder)
fn install(self: Box<Self>, app: &mut AppBuilder)
Install this plugin into the builder (register middleware, state, etc.).
Consumes the boxed plugin.
Auto Trait Implementations§
impl<S> !Freeze for TowerMiddleware<S>
impl<S> RefUnwindSafe for TowerMiddleware<S>
impl<S> Send for TowerMiddleware<S>where
S: Send,
impl<S> Sync for TowerMiddleware<S>where
S: Send,
impl<S> Unpin for TowerMiddleware<S>where
S: Unpin,
impl<S> UnsafeUnpin for TowerMiddleware<S>where
S: UnsafeUnpin,
impl<S> UnwindSafe for TowerMiddleware<S>
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