//! Request timeout middleware

use {std::time::Duration,
     tower_http::timeout::TimeoutLayer as TowerTimeoutLayer};

/// Re-export tower-http's TimeoutLayer for convenience
pub type TimeoutLayer = TowerTimeoutLayer;

/// Create a timeout layer with the specified duration
pub fn timeout(duration: Duration) -> TimeoutLayer {
  TimeoutLayer::new(duration)
}

/// Create a timeout layer with seconds
pub fn timeout_secs(secs: u64) -> TimeoutLayer {
  TimeoutLayer::new(Duration::from_secs(secs))
}
