From 6a75978c42aa856b1ac3109d706aa5bbaa233c69 Mon Sep 17 00:00:00 2001 From: tottoto Date: Sat, 12 Oct 2024 18:41:33 +0900 Subject: [PATCH] feat(router): Remove unnecessary BoxBody from response body (#1994) --- tonic/Cargo.toml | 1 + tonic/src/service/router.rs | 21 ++++++--------------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/tonic/Cargo.toml b/tonic/Cargo.toml index b400375ae..15f3dc49e 100644 --- a/tonic/Cargo.toml +++ b/tonic/Cargo.toml @@ -129,6 +129,7 @@ allowed_external_types = [ "async_trait::async_trait", "axum_core::body::Body", + "axum_core::response::into_response::IntoResponse", "axum::routing::Router", "futures_core::stream::Stream", "h2::error::Error", diff --git a/tonic/src/service/router.rs b/tonic/src/service/router.rs index efe2f7555..a4a074754 100644 --- a/tonic/src/service/router.rs +++ b/tonic/src/service/router.rs @@ -30,11 +30,8 @@ impl RoutesBuilder { /// Add a new service. pub fn add_service(&mut self, svc: S) -> &mut Self where - S: Service, Response = Response, Error = Infallible> - + NamedService - + Clone - + Send - + 'static, + S: Service, Error = Infallible> + NamedService + Clone + Send + 'static, + S::Response: axum::response::IntoResponse, S::Future: Send + 'static, { let routes = self.routes.take().unwrap_or_default(); @@ -60,11 +57,8 @@ impl Routes { /// Create a new routes with `svc` already added to it. pub fn new(svc: S) -> Self where - S: Service, Response = Response, Error = Infallible> - + NamedService - + Clone - + Send - + 'static, + S: Service, Error = Infallible> + NamedService + Clone + Send + 'static, + S::Response: axum::response::IntoResponse, S::Future: Send + 'static, { Self::default().add_service(svc) @@ -78,11 +72,8 @@ impl Routes { /// Add a new service. pub fn add_service(mut self, svc: S) -> Self where - S: Service, Response = Response, Error = Infallible> - + NamedService - + Clone - + Send - + 'static, + S: Service, Error = Infallible> + NamedService + Clone + Send + 'static, + S::Response: axum::response::IntoResponse, S::Future: Send + 'static, { self.router = self.router.route_service(