pub struct ConditionalStatus<F>{ /* private fields */ }Expand description
Middleware that sets response status code based on a condition.
This is useful for implementing health checks or conditional responses.
Implementations§
Source§impl<F> ConditionalStatus<F>
impl<F> ConditionalStatus<F>
Sourcepub fn new(
condition: F,
status_if_true: StatusCode,
status_if_false: StatusCode,
) -> Self
pub fn new( condition: F, status_if_true: StatusCode, status_if_false: StatusCode, ) -> Self
Creates a new conditional status middleware.
If the condition returns true, the response gets status_if_true.
Otherwise, it gets status_if_false.
Trait Implementations§
Source§impl<F> Clone for ConditionalStatus<F>
impl<F> Clone for ConditionalStatus<F>
Source§fn clone(&self) -> ConditionalStatus<F>
fn clone(&self) -> ConditionalStatus<F>
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<F> Debug for ConditionalStatus<F>
impl<F> Debug for ConditionalStatus<F>
Source§impl<F> Middleware for ConditionalStatus<F>
impl<F> Middleware for ConditionalStatus<F>
Source§fn after<'a>(
&'a self,
_ctx: &'a RequestContext,
req: &'a Request,
response: Response,
) -> BoxFuture<'a, Response>
fn after<'a>( &'a self, _ctx: &'a RequestContext, req: &'a Request, response: Response, ) -> BoxFuture<'a, Response>
Called after the handler executes. Read more
Source§fn name(&self) -> &'static str
fn name(&self) -> &'static str
Returns the middleware name for debugging and logging. Read more
Source§fn before<'a>(
&'a self,
_ctx: &'a RequestContext,
_req: &'a mut Request,
) -> BoxFuture<'a, ControlFlow>
fn before<'a>( &'a self, _ctx: &'a RequestContext, _req: &'a mut Request, ) -> BoxFuture<'a, ControlFlow>
Called before the handler executes. Read more
Auto Trait Implementations§
impl<F> Freeze for ConditionalStatus<F>where
F: Freeze,
impl<F> RefUnwindSafe for ConditionalStatus<F>where
F: RefUnwindSafe,
impl<F> Send for ConditionalStatus<F>
impl<F> Sync for ConditionalStatus<F>
impl<F> Unpin for ConditionalStatus<F>where
F: Unpin,
impl<F> UnwindSafe for ConditionalStatus<F>where
F: 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Instruments this future with a span (no-op when disabled).
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Instruments this future with the current span (no-op when disabled).