Skip to content

Commit

Permalink
feat(router): Remove unnecessary BoxBody from response body (#1994)
Browse files Browse the repository at this point in the history
  • Loading branch information
tottoto authored Oct 12, 2024
1 parent 0fcd63a commit 6a75978
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
1 change: 1 addition & 0 deletions tonic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
21 changes: 6 additions & 15 deletions tonic/src/service/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,8 @@ impl RoutesBuilder {
/// Add a new service.
pub fn add_service<S>(&mut self, svc: S) -> &mut Self
where
S: Service<Request<BoxBody>, Response = Response<BoxBody>, Error = Infallible>
+ NamedService
+ Clone
+ Send
+ 'static,
S: Service<Request<BoxBody>, Error = Infallible> + NamedService + Clone + Send + 'static,
S::Response: axum::response::IntoResponse,
S::Future: Send + 'static,
{
let routes = self.routes.take().unwrap_or_default();
Expand All @@ -60,11 +57,8 @@ impl Routes {
/// Create a new routes with `svc` already added to it.
pub fn new<S>(svc: S) -> Self
where
S: Service<Request<BoxBody>, Response = Response<BoxBody>, Error = Infallible>
+ NamedService
+ Clone
+ Send
+ 'static,
S: Service<Request<BoxBody>, Error = Infallible> + NamedService + Clone + Send + 'static,
S::Response: axum::response::IntoResponse,
S::Future: Send + 'static,
{
Self::default().add_service(svc)
Expand All @@ -78,11 +72,8 @@ impl Routes {
/// Add a new service.
pub fn add_service<S>(mut self, svc: S) -> Self
where
S: Service<Request<BoxBody>, Response = Response<BoxBody>, Error = Infallible>
+ NamedService
+ Clone
+ Send
+ 'static,
S: Service<Request<BoxBody>, Error = Infallible> + NamedService + Clone + Send + 'static,
S::Response: axum::response::IntoResponse,
S::Future: Send + 'static,
{
self.router = self.router.route_service(
Expand Down

0 comments on commit 6a75978

Please sign in to comment.