Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(transport): Add Router::into_router #1442

Merged
merged 2 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions tonic/src/transport/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,11 @@ impl<L> Router<L> {
self
}

/// Convert this tonic `Router` into an axum `Router` consuming the tonic one.
pub fn into_router(self) -> axum::Router {
self.routes.into_router()
}

/// Consume this [`Server`] creating a future that will execute the server
/// on [tokio]'s default executor.
///
Expand Down
5 changes: 5 additions & 0 deletions tonic/src/transport/service/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ impl Routes {
router: self.router.with_state(()),
}
}

/// Convert this `Routes` into an [`axum::Router`].
pub fn into_router(self) -> axum::Router {
self.router
}
}

async fn unimplemented() -> impl axum::response::IntoResponse {
Expand Down
Loading