-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Impossible to use tonic-web
(0.12.3) while multiplexing with axum
(0.7.7) without using the deprecated Router::into_router()
?
#1964
Comments
okay so it looks like the following works, albeit a little awkward: tonic::service::Routes::new(GrpcWebLayer::new().layer(NodeMapServer::new(NodeMapServerImpl::new(databases))))
.prepare()
.into_axum_router()
// layering etc in case anyone hits this issue as well. it would still be nice to use |
I've run into a similar problem, where I'm not sure, if it is possible to make my code work without using the deprecated method. @tottoto Could you maybe take a quick look? But there doesn't seem to be a way to convert from I'm guessing, the appropriate solution would be an implementation of the The implementation would probably look like this: impl From<tonic::transport::server::Router> for Routes {
fn from(router: tonic::transport::server::Router) -> Self {
router.routes
}
} |
There isn't need to get |
Ah, thanks, that makes more sense now. For anyone else stumbling upon this, I was able to change our code from this structure: let axum_router = tonic::transport::Server::builder()
.layer(async_interceptor(move |request| {
//...
}))
.accept_http1(true) //gRPC-Web uses HTTP1
.add_service(service1)
.add_service(service2)
.into_router(); To this: let mut routes_builder = Routes::builder();
routes_builder
.add_service(service1)
.add_service(service2);
let axum_router = routes_builder
.routes()
.into_axum_router()
.layer(async_interceptor(move |request| {
//...
})); I don't know where one would specify the |
In a situation where you might need the let axum_router = tonic::transport::Server::builder()
.layer(async_interceptor(move |request| {
//...
}))
.accept_http1(true) //gRPC-Web uses HTTP1
.add_service(service1)
.add_service(service2)
.into_router(); to let axum_router = tonic::transport::Server::builder()
.layer(async_interceptor(move |request| {
//...
}))
.accept_http1(true) //gRPC-Web uses HTTP1
.add_service(service1)
.add_service(service2)
.into_service()
.into_axum_router(); |
Bug Report
Version
Platform
N/A
Crates
Description
I'm working on upgrading some of my web services which use both gRPC (via
tonic
) and regular REST endpoints (viaaxum
) and cannot find a way to implement theGrpcWebLayer
without using the deprecatedtonic::transport::server::Router::into_router()
method because of mismatched body types.Compiles:
Does not compile:
am I missing something obvious? I'd like to not use the deprecated method if possible, but it doesn't seem possible to do so otherwise. is there a workaround available at this point or do I need for
tonic-web
to be changed to be generic over the body type? (#1361)The text was updated successfully, but these errors were encountered: