diff --git a/tonic/Cargo.toml b/tonic/Cargo.toml index 91f4c28d6..ca90731a0 100644 --- a/tonic/Cargo.toml +++ b/tonic/Cargo.toml @@ -88,7 +88,7 @@ hyper-util = { version = "0.1.4", features = ["tokio"], optional = true } socket2 = { version = "0.5", optional = true, features = ["all"] } tokio = {version = "1", default-features = false, optional = true} tower = {version = "0.5", default-features = false, optional = true} -axum = {version = "0.7", default-features = false, optional = true} +axum = {version = "=0.8.0-alpha.1", default-features = false, optional = true} # rustls rustls-pki-types = { version = "1.9", features = ["std"], optional = true } diff --git a/tonic/src/service/router.rs b/tonic/src/service/router.rs index a2d42e99a..f32487c15 100644 --- a/tonic/src/service/router.rs +++ b/tonic/src/service/router.rs @@ -25,7 +25,12 @@ impl RoutesBuilder { /// Add a new service. pub fn add_service(&mut self, svc: S) -> &mut Self where - S: Service, Error = Infallible> + NamedService + Clone + Send + 'static, + S: Service, Error = Infallible> + + NamedService + + Clone + + Send + + Sync + + 'static, S::Response: axum::response::IntoResponse, S::Future: Send + 'static, { @@ -52,7 +57,12 @@ impl Routes { /// Create a new routes with `svc` already added to it. pub fn new(svc: S) -> Self where - S: Service, Error = Infallible> + NamedService + Clone + Send + 'static, + S: Service, Error = Infallible> + + NamedService + + Clone + + Send + + Sync + + 'static, S::Response: axum::response::IntoResponse, S::Future: Send + 'static, { @@ -67,12 +77,17 @@ impl Routes { /// Add a new service. pub fn add_service(mut self, svc: S) -> Self where - S: Service, Error = Infallible> + NamedService + Clone + Send + 'static, + S: Service, Error = Infallible> + + NamedService + + Clone + + Send + + Sync + + 'static, S::Response: axum::response::IntoResponse, S::Future: Send + 'static, { self.router = self.router.route_service( - &format!("/{}/*rest", S::NAME), + &format!("/{}/{{*rest}}", S::NAME), svc.map_request(|req: Request| req.map(Body::new)), ); self diff --git a/tonic/src/transport/server/incoming.rs b/tonic/src/transport/server/incoming.rs index 3b6c22c02..b0fa74027 100644 --- a/tonic/src/transport/server/incoming.rs +++ b/tonic/src/transport/server/incoming.rs @@ -182,7 +182,7 @@ impl TcpIncoming { /// # fn main() { } // Cannot have type parameters, hence instead define: /// # fn run(some_service: S) -> Result<(), Box> /// # where - /// # S: Service, Response = Response, Error = Infallible> + NamedService + Clone + Send + 'static, + /// # S: Service, Response = Response, Error = Infallible> + NamedService + Clone + Send + Sync + 'static, /// # S::Future: Send + 'static, /// # { /// // Find a free port diff --git a/tonic/src/transport/server/mod.rs b/tonic/src/transport/server/mod.rs index 526f464ee..ce19f8f00 100644 --- a/tonic/src/transport/server/mod.rs +++ b/tonic/src/transport/server/mod.rs @@ -398,6 +398,7 @@ impl Server { + NamedService + Clone + Send + + Sync + 'static, S::Future: Send + 'static, L: Clone, @@ -419,6 +420,7 @@ impl Server { + NamedService + Clone + Send + + Sync + 'static, S::Future: Send + 'static, L: Clone, @@ -735,6 +737,7 @@ impl Router { + NamedService + Clone + Send + + Sync + 'static, S::Future: Send + 'static, { @@ -754,6 +757,7 @@ impl Router { + NamedService + Clone + Send + + Sync + 'static, S::Future: Send + 'static, {