at_jet/middleware/
timeout.rs

1//! Request timeout middleware
2
3use {std::time::Duration,
4     tower_http::timeout::TimeoutLayer as TowerTimeoutLayer};
5
6/// Re-export tower-http's TimeoutLayer for convenience
7pub type TimeoutLayer = TowerTimeoutLayer;
8
9/// Create a timeout layer with the specified duration
10pub fn timeout(duration: Duration) -> TimeoutLayer {
11  TimeoutLayer::new(duration)
12}
13
14/// Create a timeout layer with seconds
15pub fn timeout_secs(secs: u64) -> TimeoutLayer {
16  TimeoutLayer::new(Duration::from_secs(secs))
17}