Skip to content

Commit

Permalink
fix(build): Server service uses generic body bound (#306)
Browse files Browse the repository at this point in the history
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
  • Loading branch information
bnjjj committed Mar 28, 2020
1 parent e2c2be2 commit 5758b75
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
9 changes: 7 additions & 2 deletions tonic-build/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,12 @@ pub fn generate<'a, T: Service<'a>>(service: &'a T, context: &T::Context) -> Tok
}
}

impl<T: #server_trait> Service<http::Request<HyperBody>> for #server_service<T> {
impl<T, B> Service<http::Request<B>> for #server_service<T>
where
T: #server_trait,
B: HttpBody + Send + Sync + 'static,
B::Error: Into<StdError> + Send + 'static,
{
type Response = http::Response<tonic::body::BoxBody>;
type Error = Never;
type Future = BoxFuture<Self::Response, Self::Error>;
Expand All @@ -58,7 +63,7 @@ pub fn generate<'a, T: Service<'a>>(service: &'a T, context: &T::Context) -> Tok
Poll::Ready(Ok(()))
}

fn call(&mut self, req: http::Request<HyperBody>) -> Self::Future {
fn call(&mut self, req: http::Request<B>) -> Self::Future {
let inner = self.inner.clone();

match req.uri().path() {
Expand Down
3 changes: 0 additions & 3 deletions tonic/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ pub use tower_service::Service;
pub type StdError = Box<dyn std::error::Error + Send + Sync + 'static>;
pub use crate::body::Body;

#[cfg(feature = "transport")]
pub use hyper::Body as HyperBody;

pub type BoxFuture<T, E> = self::Pin<Box<dyn self::Future<Output = Result<T, E>> + Send + 'static>>;
pub type BoxStream<T> =
self::Pin<Box<dyn futures_core::Stream<Item = Result<T, crate::Status>> + Send + 'static>>;
Expand Down

0 comments on commit 5758b75

Please sign in to comment.