pub struct DelayLayer { /* private fields */ }Available on crate feature
tower-delay only.Expand description
A Tower Layer that introduces a fixed delay before each request.
Implementations§
Source§impl DelayLayer
impl DelayLayer
Sourcepub const fn new(delay: Duration) -> Self
pub const fn new(delay: Duration) -> Self
Create a new DelayLayer with the given delay duration.
Sourcepub fn when<P, Req>(self, predicate: P) -> DelayLayerWith<P>
pub fn when<P, Req>(self, predicate: P) -> DelayLayerWith<P>
Apply delay only to requests that satisfy a predicate.
Requests that don’t match the predicate will pass through without delay.
§Example
ⓘ
use std::time::Duration;
use http::Request;
use hpx_util::tower::delay::DelayLayer;
// Only delay POST requests
let layer = DelayLayer::new(Duration::from_secs(1))
.when(|req: &Request<_>| req.method() == http::Method::POST);Trait Implementations§
Source§impl Clone for DelayLayer
impl Clone for DelayLayer
Source§fn clone(&self) -> DelayLayer
fn clone(&self) -> DelayLayer
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 Debug for DelayLayer
impl Debug for DelayLayer
Auto Trait Implementations§
impl Freeze for DelayLayer
impl RefUnwindSafe for DelayLayer
impl Send for DelayLayer
impl Sync for DelayLayer
impl Unpin for DelayLayer
impl UnsafeUnpin for DelayLayer
impl UnwindSafe for DelayLayer
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