Skip to content

Commit d8ca2b0

Browse files
committed
chore(router): Update to axum 0.8
1 parent 64c6906 commit d8ca2b0

File tree

4 files changed

+25
-6
lines changed

4 files changed

+25
-6
lines changed

tonic/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ hyper-util = { version = "0.1.4", features = ["tokio"], optional = true }
8888
socket2 = { version = "0.5", optional = true, features = ["all"] }
8989
tokio = {version = "1", default-features = false, optional = true}
9090
tower = {version = "0.5", default-features = false, optional = true}
91-
axum = {version = "0.7", default-features = false, optional = true}
91+
axum = {version = "=0.8.0-alpha.1", default-features = false, optional = true}
9292

9393
# rustls
9494
rustls-pki-types = { version = "1.9", features = ["std"], optional = true }

tonic/src/service/router.rs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@ impl RoutesBuilder {
2525
/// Add a new service.
2626
pub fn add_service<S>(&mut self, svc: S) -> &mut Self
2727
where
28-
S: Service<Request<Body>, Error = Infallible> + NamedService + Clone + Send + 'static,
28+
S: Service<Request<Body>, Error = Infallible>
29+
+ NamedService
30+
+ Clone
31+
+ Send
32+
+ Sync
33+
+ 'static,
2934
S::Response: axum::response::IntoResponse,
3035
S::Future: Send + 'static,
3136
{
@@ -52,7 +57,12 @@ impl Routes {
5257
/// Create a new routes with `svc` already added to it.
5358
pub fn new<S>(svc: S) -> Self
5459
where
55-
S: Service<Request<Body>, Error = Infallible> + NamedService + Clone + Send + 'static,
60+
S: Service<Request<Body>, Error = Infallible>
61+
+ NamedService
62+
+ Clone
63+
+ Send
64+
+ Sync
65+
+ 'static,
5666
S::Response: axum::response::IntoResponse,
5767
S::Future: Send + 'static,
5868
{
@@ -67,12 +77,17 @@ impl Routes {
6777
/// Add a new service.
6878
pub fn add_service<S>(mut self, svc: S) -> Self
6979
where
70-
S: Service<Request<Body>, Error = Infallible> + NamedService + Clone + Send + 'static,
80+
S: Service<Request<Body>, Error = Infallible>
81+
+ NamedService
82+
+ Clone
83+
+ Send
84+
+ Sync
85+
+ 'static,
7186
S::Response: axum::response::IntoResponse,
7287
S::Future: Send + 'static,
7388
{
7489
self.router = self.router.route_service(
75-
&format!("/{}/*rest", S::NAME),
90+
&format!("/{}/{{*rest}}", S::NAME),
7691
svc.map_request(|req: Request<axum::body::Body>| req.map(Body::new)),
7792
);
7893
self

tonic/src/transport/server/incoming.rs

Lines changed: 1 addition & 1 deletion
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<Body>, Response = Response<Body>, Error = Infallible> + NamedService + Clone + Send + 'static,
185+
/// # S: Service<Request<Body>, Response = Response<Body>, Error = Infallible> + NamedService + Clone + Send + Sync + 'static,
186186
/// # S::Future: Send + 'static,
187187
/// # {
188188
/// // Find a free port

tonic/src/transport/server/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@ impl<L> Server<L> {
398398
+ NamedService
399399
+ Clone
400400
+ Send
401+
+ Sync
401402
+ 'static,
402403
S::Future: Send + 'static,
403404
L: Clone,
@@ -419,6 +420,7 @@ impl<L> Server<L> {
419420
+ NamedService
420421
+ Clone
421422
+ Send
423+
+ Sync
422424
+ 'static,
423425
S::Future: Send + 'static,
424426
L: Clone,
@@ -735,6 +737,7 @@ impl<L> Router<L> {
735737
+ NamedService
736738
+ Clone
737739
+ Send
740+
+ Sync
738741
+ 'static,
739742
S::Future: Send + 'static,
740743
{
@@ -754,6 +757,7 @@ impl<L> Router<L> {
754757
+ NamedService
755758
+ Clone
756759
+ Send
760+
+ Sync
757761
+ 'static,
758762
S::Future: Send + 'static,
759763
{

0 commit comments

Comments
 (0)