Skip to content

Commit 7591157

Browse files
committed
chore(router): Update to axum 0.8
1 parent da02b2f commit 7591157

File tree

4 files changed

+25
-6
lines changed

4 files changed

+25
-6
lines changed

tonic/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ hyper-util = { version = "0.1.4", features = ["tokio"], optional = true }
8585
socket2 = { version = "0.5", optional = true, features = ["all"] }
8686
tokio = {version = "1", default-features = false, optional = true}
8787
tower = {version = "0.5", default-features = false, optional = true}
88-
axum = {version = "0.7", default-features = false, optional = true}
88+
axum = {version = "=0.8.0-alpha.1", default-features = false, optional = true}
8989

9090
# rustls
9191
rustls-pemfile = { version = "2.0", optional = true }

tonic/src/service/router.rs

+19-4
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,12 @@ impl RoutesBuilder {
3030
/// Add a new service.
3131
pub fn add_service<S>(&mut self, svc: S) -> &mut Self
3232
where
33-
S: Service<Request<BoxBody>, Error = Infallible> + NamedService + Clone + Send + 'static,
33+
S: Service<Request<BoxBody>, Error = Infallible>
34+
+ NamedService
35+
+ Clone
36+
+ Send
37+
+ Sync
38+
+ 'static,
3439
S::Response: axum::response::IntoResponse,
3540
S::Future: Send + 'static,
3641
{
@@ -57,7 +62,12 @@ impl Routes {
5762
/// Create a new routes with `svc` already added to it.
5863
pub fn new<S>(svc: S) -> Self
5964
where
60-
S: Service<Request<BoxBody>, Error = Infallible> + NamedService + Clone + Send + 'static,
65+
S: Service<Request<BoxBody>, Error = Infallible>
66+
+ NamedService
67+
+ Clone
68+
+ Send
69+
+ Sync
70+
+ 'static,
6171
S::Response: axum::response::IntoResponse,
6272
S::Future: Send + 'static,
6373
{
@@ -72,12 +82,17 @@ impl Routes {
7282
/// Add a new service.
7383
pub fn add_service<S>(mut self, svc: S) -> Self
7484
where
75-
S: Service<Request<BoxBody>, Error = Infallible> + NamedService + Clone + Send + 'static,
85+
S: Service<Request<BoxBody>, Error = Infallible>
86+
+ NamedService
87+
+ Clone
88+
+ Send
89+
+ Sync
90+
+ 'static,
7691
S::Response: axum::response::IntoResponse,
7792
S::Future: Send + 'static,
7893
{
7994
self.router = self.router.route_service(
80-
&format!("/{}/*rest", S::NAME),
95+
&format!("/{}/{{*rest}}", S::NAME),
8196
svc.map_request(|req: Request<axum::body::Body>| req.map(boxed)),
8297
);
8398
self

tonic/src/transport/server/incoming.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ impl TcpIncoming {
182182
/// # fn main() { } // Cannot have type parameters, hence instead define:
183183
/// # fn run<S>(some_service: S) -> Result<(), Box<dyn Error + Send + Sync>>
184184
/// # where
185-
/// # S: Service<Request<BoxBody>, Response = Response<BoxBody>, Error = Infallible> + NamedService + Clone + Send + 'static,
185+
/// # S: Service<Request<BoxBody>, Response = Response<BoxBody>, Error = Infallible> + NamedService + Clone + Send + Sync + 'static,
186186
/// # S::Future: Send + 'static,
187187
/// # {
188188
/// // Find a free port

tonic/src/transport/server/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,7 @@ impl<L> Server<L> {
403403
+ NamedService
404404
+ Clone
405405
+ Send
406+
+ Sync
406407
+ 'static,
407408
S::Future: Send + 'static,
408409
L: Clone,
@@ -424,6 +425,7 @@ impl<L> Server<L> {
424425
+ NamedService
425426
+ Clone
426427
+ Send
428+
+ Sync
427429
+ 'static,
428430
S::Future: Send + 'static,
429431
L: Clone,
@@ -742,6 +744,7 @@ impl<L> Router<L> {
742744
+ NamedService
743745
+ Clone
744746
+ Send
747+
+ Sync
745748
+ 'static,
746749
S::Future: Send + 'static,
747750
{
@@ -761,6 +764,7 @@ impl<L> Router<L> {
761764
+ NamedService
762765
+ Clone
763766
+ Send
767+
+ Sync
764768
+ 'static,
765769
S::Future: Send + 'static,
766770
{

0 commit comments

Comments
 (0)