You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sorry for raising this issue if I missed some info.
Can't use tonic Routes with axum router with its own fallback: Cannot merge two Routers that both have a fallback. This is an axum error, but it appears that tonic Routes by default set fallback:
As a result in example like this you receive an error, then have to find where another fallback comes from so to overwrite it or if you don'y use any fallback you get one from tonic Routes for all of your handlers which might be unexpected or not very obvious.
asyncfnhello() -> impl axum::response::IntoResponse{"Hello, World!"}asyncfnim_a_teapot() -> impl axum::response::IntoResponse{(StatusCode::IM_A_TEAPOT,"IM_A_TEAPOT")}#[tokio::main]asyncfnmain(){let app = Router::new().route("/hello",get(hello));// .fallback(im_a_teapot); <--- if added will fail in runtime.let tonic_routes = Routes::new(EchoServer::new(MyEcho)).into_axum_router();let app = app.merge(tonic_routes);let listener = tokio::net::TcpListener::bind("127.0.0.1:8000").await.unwrap();
axum::serve(listener, app).await.unwrap();}
Feature Request
Motivation
Sorry for raising this issue if I missed some info.
Can't use tonic Routes with axum router with its own fallback:
Cannot merge two
Routers that both have a fallback
. This is an axum error, but it appears that tonic Routes by default set fallback:tonic/tonic/src/service/router.rs
Line 54 in 6d93c1d
As a result in example like this you receive an error, then have to find where another fallback comes from so to overwrite it or if you don'y use any fallback you get one from tonic Routes for all of your handlers which might be unexpected or not very obvious.
Proposal
Remove default fallback from:
tonic/tonic/src/service/router.rs
Line 54 in 6d93c1d
Alternatives
The text was updated successfully, but these errors were encountered: