tonic-web

Crates.iotonic-web
lib.rstonic-web
version0.14.2
created_at2021-07-08 19:57:33.767242+00
updated_at2025-09-02 17:43:16.784758+00
descriptiongrpc-web protocol translation for tonic services.
homepagehttps://github.com/hyperium/tonic
repositoryhttps://github.com/hyperium/tonic
max_upload_size
id420459
size1,469,112
Lucio Franco (LucioFranco)

documentation

README

tonic-web

Enables tonic servers to handle requests from grpc-web clients directly, without the need of an external proxy.

Enabling tonic services

The easiest way to get started, is to call the function with your tonic service and allow the tonic server to accept HTTP/1.1 requests:

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let addr = "[::1]:50051".parse().unwrap();
    let greeter = GreeterServer::new(MyGreeter::default());

   Server::builder()
       .accept_http1(true)
       .layer(GrpcWebLayer::new())
       .add_service(greeter)
       .serve(addr)
       .await?;

   Ok(())
}

Examples

See the examples folder for a server and client example.

Commit count: 1315

cargo fmt