Skip to content

Commit

Permalink
chore(router): Update to axum 0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
tottoto committed Oct 12, 2024
1 parent 574c6b4 commit 438296d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
2 changes: 1 addition & 1 deletion tonic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,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.4.7", 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-pemfile = { version = "2.0", optional = true }
Expand Down
23 changes: 19 additions & 4 deletions tonic/src/service/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ impl RoutesBuilder {
/// Add a new service.
pub fn add_service<S>(&mut self, svc: S) -> &mut Self
where
S: Service<Request<BoxBody>, Error = Infallible> + NamedService + Clone + Send + 'static,
S: Service<Request<BoxBody>, Error = Infallible>
+ NamedService
+ Clone
+ Send
+ Sync
+ 'static,
S::Response: axum::response::IntoResponse,
S::Future: Send + 'static,
{
Expand All @@ -57,7 +62,12 @@ impl Routes {
/// Create a new routes with `svc` already added to it.
pub fn new<S>(svc: S) -> Self
where
S: Service<Request<BoxBody>, Error = Infallible> + NamedService + Clone + Send + 'static,
S: Service<Request<BoxBody>, Error = Infallible>
+ NamedService
+ Clone
+ Send
+ Sync
+ 'static,
S::Response: axum::response::IntoResponse,
S::Future: Send + 'static,
{
Expand All @@ -72,12 +82,17 @@ impl Routes {
/// Add a new service.
pub fn add_service<S>(mut self, svc: S) -> Self
where
S: Service<Request<BoxBody>, Error = Infallible> + NamedService + Clone + Send + 'static,
S: Service<Request<BoxBody>, 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<axum::body::Body>| req.map(boxed)),
);
self
Expand Down
2 changes: 1 addition & 1 deletion tonic/src/transport/server/incoming.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ impl TcpIncoming {
/// # fn main() { } // Cannot have type parameters, hence instead define:
/// # fn run<S>(some_service: S) -> Result<(), Box<dyn Error + Send + Sync>>
/// # where
/// # S: Service<Request<BoxBody>, Response = Response<BoxBody>, Error = Infallible> + NamedService + Clone + Send + 'static,
/// # S: Service<Request<BoxBody>, Response = Response<BoxBody>, Error = Infallible> + NamedService + Clone + Send + Sync + 'static,
/// # S::Future: Send + 'static,
/// # {
/// // Find a free port
Expand Down
4 changes: 4 additions & 0 deletions tonic/src/transport/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ impl<L> Server<L> {
+ NamedService
+ Clone
+ Send
+ Sync
+ 'static,
S::Future: Send + 'static,
L: Clone,
Expand All @@ -423,6 +424,7 @@ impl<L> Server<L> {
+ NamedService
+ Clone
+ Send
+ Sync
+ 'static,
S::Future: Send + 'static,
L: Clone,
Expand Down Expand Up @@ -741,6 +743,7 @@ impl<L> Router<L> {
+ NamedService
+ Clone
+ Send
+ Sync
+ 'static,
S::Future: Send + 'static,
{
Expand All @@ -760,6 +763,7 @@ impl<L> Router<L> {
+ NamedService
+ Clone
+ Send
+ Sync
+ 'static,
S::Future: Send + 'static,
{
Expand Down

0 comments on commit 438296d

Please sign in to comment.