From 02c2bd337fe438d6d43f1efecfe37aee1c2d253b Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 5 Jan 2025 15:07:28 +0000 Subject: [PATCH 1/4] Update Rust crate axum to 0.8 --- Cargo.lock | 14 ++++++-------- router/Cargo.toml | 2 +- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 58878d5..aec53fa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -166,11 +166,10 @@ checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "axum" -version = "0.7.9" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edca88bc138befd0323b20752846e6587272d3b03b0343c8ea28a6f819e6e71f" +checksum = "6d6fd624c75e18b3b4c6b9caf42b1afe24437daaee904069137d8bab077be8b8" dependencies = [ - "async-trait", "axum-core", "bytes", "futures-util", @@ -199,11 +198,10 @@ dependencies = [ [[package]] name = "axum-core" -version = "0.4.5" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09f2bd6146b97ae3359fa0cc6d6b376d9539582c7b4220f041a33ec24c226199" +checksum = "df1362f362fd16024ae199c1970ce98f9661bf5ef94b9808fee734bc3698b733" dependencies = [ - "async-trait", "bytes", "futures-util", "http", @@ -1393,9 +1391,9 @@ dependencies = [ [[package]] name = "matchit" -version = "0.7.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" +checksum = "47e1ffaa40ddd1f3ed91f717a33c8c0ee23fff369e3aa8772b9605cc1d22f4c3" [[package]] name = "md-5" diff --git a/router/Cargo.toml b/router/Cargo.toml index 9cb2709..ed1f436 100644 --- a/router/Cargo.toml +++ b/router/Cargo.toml @@ -13,7 +13,7 @@ serde_json.workspace = true tracing.workspace = true async-trait = "0.1" http.workspace = true -axum.version = "0.7" +axum.version = "0.8" axum.default-features = false axum.features = ["tokio", "http1", "matched-path", "tower-log", "tracing", "json"] From 961bd9a389c8456ae192fed4a9a5393b58c6917a Mon Sep 17 00:00:00 2001 From: H1rono Date: Mon, 6 Jan 2025 16:04:06 +0900 Subject: [PATCH 2/4] :fire: Remove `#[async_trait::async_trait]` --- router/src/webhook.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/router/src/webhook.rs b/router/src/webhook.rs index 04e47ff..24b3bb7 100644 --- a/router/src/webhook.rs +++ b/router/src/webhook.rs @@ -1,4 +1,3 @@ -use async_trait::async_trait; use axum::{ extract::{FromRequestParts, Path, State}, response::IntoResponse, @@ -37,7 +36,6 @@ impl IntoResponse for WhRejection { } } -#[async_trait] impl FromRequestParts for Wh where S: AppState, From 7a86cb0d28b3bf8d6b4aed678f4b2729a0d80027 Mon Sep 17 00:00:00 2001 From: H1rono Date: Mon, 6 Jan 2025 16:09:43 +0900 Subject: [PATCH 3/4] :recycle: Change `Bot::build_service` signature --- app/bot/src/lib.rs | 5 +++-- usecases/src/bot.rs | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/bot/src/lib.rs b/app/bot/src/lib.rs index edad6b9..3d4c046 100644 --- a/app/bot/src/lib.rs +++ b/app/bot/src/lib.rs @@ -1,6 +1,7 @@ use std::sync::Arc; use http::Request; +use tower::util::BoxCloneSyncService; use traq_bot_http::RequestParser; use domain::Infra; @@ -37,7 +38,7 @@ impl Bot for BotImpl { fn build_service( self, infra: Arc, - ) -> tower::util::BoxCloneService, http::Response, domain::Error> + ) -> BoxCloneSyncService, http::Response, domain::Error> where B: http_body::Body + Send + 'static, B::Data: Send + 'static, @@ -57,7 +58,7 @@ impl Bot for BotImpl { .map_request(|r: Request| r) .map_err(Error::TraqBot) .map_err(domain::Error::from); - handler.boxed_clone() + BoxCloneSyncService::new(handler) } } diff --git a/usecases/src/bot.rs b/usecases/src/bot.rs index 238b5b8..4516222 100644 --- a/usecases/src/bot.rs +++ b/usecases/src/bot.rs @@ -2,7 +2,7 @@ use std::sync::Arc; use http::{Request, Response}; use http_body::Body; -use tower::util::BoxCloneService; +use tower::util::BoxCloneSyncService; use domain::Infra; @@ -11,7 +11,7 @@ pub trait Bot { fn build_service( self, infra: Arc, - ) -> BoxCloneService, Response, domain::Error> + ) -> BoxCloneSyncService, Response, domain::Error> where B: Body + Send + 'static, B::Data: Send + 'static, From 020f41880a5847ea1cae2df4d911c9a826a94bef Mon Sep 17 00:00:00 2001 From: H1rono Date: Mon, 6 Jan 2025 16:12:12 +0900 Subject: [PATCH 4/4] :arrow_up: Update path parameter syntax --- router/src/lib.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/router/src/lib.rs b/router/src/lib.rs index ead3384..a7e9092 100644 --- a/router/src/lib.rs +++ b/router/src/lib.rs @@ -90,17 +90,20 @@ where }); Router::new() .route("/bot", bot_service) - .route("/wh/:id", get(get_wh::>)) .route( - "/wh/:id/github", + "/wh/{id}", + get(get_wh::>), + ) + .route( + "/wh/{id}/github", post(wh_github::>), ) .route( - "/wh/:id/gitea", + "/wh/{id}/gitea", post(wh_gitea::>), ) .route( - "/wh/:id/clickup", + "/wh/{id}/clickup", post(wh_clickup::>), ) .with_state(state)