Closed rohitjoshi closed 2 years ago
Sounds like you're asking for this example https://github.com/tokio-rs/axum/blob/main/examples/rest-grpc-multiplex/src/main.rs. That combines a REST and gRPC service into one and dispatches based on the content-type. All possible thanks to tower::Service
.
Actually tonic already uses axum internally for routing. See https://github.com/hyperium/tonic/blob/master/tonic/src/transport/service/router.rs
Thanks. Closing..
Feature Request
Supporting gRPC (tonic) based on the content-type header. I came across "Combining Axum, Hyper, Tonic, and Tower for hybrid web/gRPC apps" which shows the gRPC with Axum but seems cumbersome.
Motivation
This will enable browser support and code reuse across both HTTP1/1 and gRPC clients.
Proposal
It would be good to provide native support with maybe a separate crate e.g. axum-grpc.
Alternatives