Skip to content

feat(router): Remove unnecessary BoxBody from response body #1994

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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