diff --git a/tonic/Cargo.toml b/tonic/Cargo.toml index 1ee5c6a4d..c89bd2199 100644 --- a/tonic/Cargo.toml +++ b/tonic/Cargo.toml @@ -84,7 +84,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-rc.1", default-features = false, optional = true} # rustls rustls-native-certs = { version = "0.8", optional = true } diff --git a/tonic/src/service/router.rs b/tonic/src/service/router.rs index 17b4423dd..9c6fade35 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 a3ff0da07..3b99a98bc 100644 --- a/tonic/src/transport/server/incoming.rs +++ b/tonic/src/transport/server/incoming.rs @@ -36,7 +36,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 8e8c1c361..cc2758003 100644 --- a/tonic/src/transport/server/mod.rs +++ b/tonic/src/transport/server/mod.rs @@ -395,7 +395,12 @@ impl Server { /// route around different services. pub fn add_service(&mut self, svc: S) -> Router 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, L: Clone, @@ -413,7 +418,12 @@ impl Server { /// As a result, one cannot use this to toggle between two identically named implementations. pub fn add_optional_service(&mut self, svc: Option) -> Router 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, L: Clone, @@ -726,7 +736,12 @@ impl Router { /// Add a new service to this router. 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, { @@ -741,7 +756,12 @@ impl Router { /// As a result, one cannot use this to toggle between two identically named implementations. pub fn add_optional_service(mut self, svc: Option) -> 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, {