Crates.io | tonic-web |
lib.rs | tonic-web |
version | 0.12.3 |
source | src |
created_at | 2021-07-08 19:57:33.767242 |
updated_at | 2024-09-26 17:09:56.06856 |
description | grpc-web protocol translation for tonic services. |
homepage | https://github.com/hyperium/tonic |
repository | https://github.com/hyperium/tonic |
max_upload_size | |
id | 420459 |
size | 1,455,387 |
Enables tonic servers to handle requests from grpc-web
clients directly,
without the need of an external proxy.
[dependencies]
tonic-web = "<tonic-web-version>"
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(())
}
See the examples folder for a server and client example.