tonic-web-arcanyx-fork

Crates.iotonic-web-arcanyx-fork
lib.rstonic-web-arcanyx-fork
version0.8.1-alpha.1
sourcesrc
created_at2022-08-29 18:22:48.542466
updated_at2022-08-29 23:06:15.72996
descriptiongrpc-web protocol translation for tonic services.
homepagehttps://github.com/hyperium/tonic
repositoryhttps://github.com/arcanyx-pub/tonic
max_upload_size
id654706
size52,703
Joe Dahlquist (jdahlq)

documentation

https://docs.rs/tonic-web/0.4.0/tonic-web/

README

tonic-web

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

Getting Started

[dependencies]
tonic-web = "<tonic-web-version>"

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)
       .add_service(tonic_web::enable(greeter))
       .serve(addr)
       .await?;

   Ok(())
}

Examples

See the examples folder for a server and client example.

Commit count: 603

cargo fmt