Skip to content

Commit ea06a1b

Browse files
authoredAug 2, 2023
feat(transport): Add Router::into_router (#1442)
This adds `into_router` to tonic's `Router` that will convert it into an `axum::Router`.
1 parent d44925b commit ea06a1b

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed
 

‎tonic/src/transport/server/mod.rs

+5
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,11 @@ impl<L> Router<L> {
571571
self
572572
}
573573

574+
/// Convert this tonic `Router` into an axum `Router` consuming the tonic one.
575+
pub fn into_router(self) -> axum::Router {
576+
self.routes.into_router()
577+
}
578+
574579
/// Consume this [`Server`] creating a future that will execute the server
575580
/// on [tokio]'s default executor.
576581
///

‎tonic/src/transport/service/router.rs

+5
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ impl Routes {
6060
router: self.router.with_state(()),
6161
}
6262
}
63+
64+
/// Convert this `Routes` into an [`axum::Router`].
65+
pub fn into_router(self) -> axum::Router {
66+
self.router
67+
}
6368
}
6469

6570
async fn unimplemented() -> impl axum::response::IntoResponse {

0 commit comments

Comments
 (0)
Please sign in to comment.