Router exposes a family of stringly-typed route_* methods:
pub fn route(self, service_name: &str, method_name: &str, handler: ...) -> Self
pub fn route_view_idempotent(self, service_name: &str, method_name: &str, handler: ...) -> Self
pub fn route_view_server_stream(...)
pub fn route_view_client_stream(...)
pub fn route_view_bidi_stream(...)
// ... 8 variants total
A typo in service_name or method_name produces a runtime Unimplemented for clients — not a compile error. The generated <Service>Ext::register path avoids this entirely (it passes the *_SERVICE_NAME constants), but the manual route_* family is what shows up first in Router's rustdoc, so it's the API new users see and the one that invites the bug.
These methods are essentially codegen plumbing. They need to remain pub so generated code can call them, but they shouldn't be the documented entry point for end users.
Proposed direction
#[doc(hidden)] on the route_* family, with a doc note pointing at the generated register extension trait as the supported path.
- If a manual-routing escape hatch is genuinely needed (e.g. proxies that route without codegen), expose one that takes typed arguments — a
MethodDescriptor/Spec struct rather than two &strs — so a typo is at least a MethodDescriptor construction error rather than a silent Unimplemented.
- Consider collapsing the 8
route_view_* variants into one route_view::<...>(spec, handler) form that takes an RpcKind enum, reducing the surface even on the codegen side.
Scope
Small (#[doc(hidden] + doc updates), or medium if we also collapse the variants.
Routerexposes a family of stringly-typedroute_*methods:A typo in
service_nameormethod_nameproduces a runtimeUnimplementedfor clients — not a compile error. The generated<Service>Ext::registerpath avoids this entirely (it passes the*_SERVICE_NAMEconstants), but the manualroute_*family is what shows up first inRouter's rustdoc, so it's the API new users see and the one that invites the bug.These methods are essentially codegen plumbing. They need to remain
pubso generated code can call them, but they shouldn't be the documented entry point for end users.Proposed direction
#[doc(hidden)]on theroute_*family, with a doc note pointing at the generatedregisterextension trait as the supported path.MethodDescriptor/Specstruct rather than two&strs — so a typo is at least aMethodDescriptorconstruction error rather than a silentUnimplemented.route_view_*variants into oneroute_view::<...>(spec, handler)form that takes anRpcKindenum, reducing the surface even on the codegen side.Scope
Small (
#[doc(hidden]+ doc updates), or medium if we also collapse the variants.