merge_grpc_routes

Function merge_grpc_routes 

Source
pub fn merge_grpc_routes(http_router: Router, grpc_routes: Routes) -> Router
Expand description

Merges gRPC routes into an HTTP router.

The returned router serves both route sets, and answers anything that matches neither with unmatched_route. The gRPC routes are additionally wrapped in GrpcTimeoutLayer, so a caller’s grpc-timeout deadline is enforced.

tonic installs its own fallback on Routes to return gRPC UNIMPLEMENTED, and axum refuses to merge two routers that both define one, so that fallback is dropped in favor of the protocol-aware one. Any fallback set on http_router is dropped for the same reason: register a catch-all route instead if you need one.

§Panics

Panics if the two route sets define the same path, which is Router::merge’s behavior. In practice this can only happen if an HTTP route is registered under a path that looks like a gRPC method.