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

Make the tonic-web layer axum compatible #2157

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

MarkusTieger
Copy link

@MarkusTieger MarkusTieger commented Jan 22, 2025

Motivation

So tonic-web can be used with axum-multiplexing.
For example: (GenericAuthenticationServiceServer and GenericAuthenticationService are from my own project, don't get confused)

let mut routes = Routes::builder();

routes.add_service(GenericAuthenticationServiceServer::new(
   crate::services::auth::GenericAuthenticationService {
     backend: self.backend.clone(),
   },
));
let router: axum::Router = routes
            .routes()
            .into_axum_router()
            .layer(GrpcWebLayer::new());

// This router can now be used in combination with normal http routes.

Solution

With this pr you can just .layer(GrpcWebLayer::new()) on a normal axum router (as long as the axum feature is enabled)

Fixes #1964

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant