README.md
1# tonic-web
2
3Enables tonic servers to handle requests from `grpc-web` clients directly,
4without the need of an external proxy.
5
6## Enabling tonic services
7
8The easiest way to get started, is to call the function with your tonic service
9and allow the tonic server to accept HTTP/1.1 requests:
10
11```rust
12#[tokio::main]
13async fn main() -> Result<(), Box<dyn std::error::Error>> {
14 let addr = "[::1]:50051".parse().unwrap();
15 let greeter = GreeterServer::new(MyGreeter::default());
16
17 Server::builder()
18 .accept_http1(true)
19 .layer(GrpcWebLayer::new())
20 .add_service(greeter)
21 .serve(addr)
22 .await?;
23
24 Ok(())
25}
26```
27
28## Examples
29
30See [the examples folder][example] for a server and client example.
31
32[example]: https://github.com/hyperium/tonic/tree/master/examples/src/grpc-web
33