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 22, 2024
1 parent 5ba1f91 commit ced0334
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.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-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 @@ -182,7 +182,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 @@ -403,6 +403,7 @@ impl<L> Server<L> {
+ NamedService
+ Clone
+ Send
+ Sync
+ 'static,
S::Future: Send + 'static,
L: Clone,
Expand All @@ -424,6 +425,7 @@ impl<L> Server<L> {
+ NamedService
+ Clone
+ Send
+ Sync
+ 'static,
S::Future: Send + 'static,
L: Clone,
Expand Down Expand Up @@ -742,6 +744,7 @@ impl<L> Router<L> {
+ NamedService
+ Clone
+ Send
+ Sync
+ 'static,
S::Future: Send + 'static,
{
Expand All @@ -761,6 +764,7 @@ impl<L> Router<L> {
+ NamedService
+ Clone
+ Send
+ Sync
+ 'static,
S::Future: Send + 'static,
{
Expand Down

0 comments on commit ced0334

Please sign in to comment.