Skip to content

Commit 71dcf86

Browse files
authored
chore(router): Relax service body type for routes (#2001)
1 parent e17ecb5 commit 71dcf86

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

tonic/src/service/router.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,11 @@ async fn unimplemented() -> impl axum::response::IntoResponse {
140140
(status, headers)
141141
}
142142

143-
impl Service<Request<BoxBody>> for Routes {
143+
impl<B> Service<Request<B>> for Routes
144+
where
145+
B: http_body::Body<Data = bytes::Bytes> + Send + 'static,
146+
B::Error: Into<crate::Error>,
147+
{
144148
type Response = Response<BoxBody>;
145149
type Error = crate::Error;
146150
type Future = RoutesFuture;
@@ -150,8 +154,8 @@ impl Service<Request<BoxBody>> for Routes {
150154
Poll::Ready(Ok(()))
151155
}
152156

153-
fn call(&mut self, req: Request<BoxBody>) -> Self::Future {
154-
RoutesFuture(self.router.call(req))
157+
fn call(&mut self, req: Request<B>) -> Self::Future {
158+
RoutesFuture(self.router.call(req.map(axum::body::Body::new)))
155159
}
156160
}
157161

0 commit comments

Comments
 (0)