Generated server's service should not match full paths
- Dominant language
- Rust
- Stars
- 12.5k
- Forks
- 1.3k
- Avg merge
- 4d 7h
- Merged PRs (30d)
- 24
Description
## Feature Request
tonic-build 0.9.2 generates `tonic::codegen::Service` with every call matching full `URI` instead of stripping service prefix
It should strip prefix `//` and match only on method name (or better use hash)
### Crates
```
tonic-build 0.9.2
```
### Motivation
Performance
### Proposal
Generated code could be simple along lines of something like:
```
impl tonic::codegen::Service> for TaskServer
where
T: Task,
B: Body + Send + 'static,
B::Error: Into + Send + 'static,
{
type Response = http::Response;
type Error = std::convert::Infallible;
type Future = BoxFuture;
fn poll_ready(
&mut self,
_cx: &mut Context<'_>,
) -> Poll> {
Poll::Ready(Ok(()))
}
fn call(&mut self, req: http::Request) -> Self::Future {
let inner = self.inner.clone();
let path = req.uri().path();
if let Some(method) = path.strip_prefix("/tasks.Task/") {
match method {
"method1" => todo!(),
_ => todo!(),
}
}
}
}
```
Contributor guide
Assessment
This issue has not been assessed yet.