From 562efc6e327791c3d400601cc1179f5064573766 Mon Sep 17 00:00:00 2001 From: Ragib Badaruddin Date: Mon, 26 Aug 2024 14:48:22 +0800 Subject: [PATCH] try fix timeoutlayer --- src/main.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 7e16062..e9abe91 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,7 +11,7 @@ use logs_store::LogsStore; use tokio::signal::unix::{signal, SignalKind}; use tokio_util::{sync::CancellationToken, task::TaskTracker}; use tower_http::services::ServeDir; -use tower_http::timeout::TimeoutLayer; +use tower_http::timeout::{RequestBodyTimeoutLayer, ResponseBodyTimeoutLayer, TimeoutLayer}; use crate::handler::{get_logs, get_logs_api}; use crate::tasks::certbot::CertbotTask; @@ -46,11 +46,13 @@ struct Args { fn make_service(logs_store: LogsStore) -> IntoMakeServiceWithConnectInfo { let app = Router::new() - .layer(TimeoutLayer::new(Duration::from_secs(5))) .route("/logs", get(get_logs)) .route("/api/logs", get(get_logs_api)) .with_state(logs_store) - .nest_service("/.well-known/", ServeDir::new("./html/.well-known")); + .nest_service("/.well-known/", ServeDir::new("./html/.well-known")) + .layer(RequestBodyTimeoutLayer::new(Duration::from_secs(1))) + .layer(ResponseBodyTimeoutLayer::new(Duration::from_secs(1))) + .layer(TimeoutLayer::new(Duration::from_secs(1))); app.into_make_service_with_connect_info::() }