When using Tonic (Grpc for Rust) how to strip url path prefix?

63 views Asked by At

I try to use grpc-web and my reverse proxy doesn't provide mechanism to strip api url prefix like '/api' from requests forwarded to backend. Is it a way to configure tonic to strip '/api' prefix from incoming request so that it can response to '/api/myapi.v1.GreetingService/Hello' same as to '/myapi.v1.GreetingService/Hello' ?

use tonic::transport::Server;
use tonic_web::GrpcWebLayer;

#[tokio::main(flavor = "current_thread")]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let addr = "[::1]:8080".parse()?;
    Server::builder()
        .accept_http1(true)
        .layer(GrpcWebLayer::new())
        .serve(addr)
        .await?;

    Ok(())
}
0

There are 0 answers