fix(web): Fix enable and update docs (#1326)
* fix(web): Fix `enable` and update docs * fix example, update deny * fix namedservice path
This commit is contained in:
@@ -2,8 +2,6 @@ use tonic::{transport::Server, Request, Response, Status};
|
||||
|
||||
use hello_world::greeter_server::{Greeter, GreeterServer};
|
||||
use hello_world::{HelloReply, HelloRequest};
|
||||
use tonic_web::GrpcWebLayer;
|
||||
use tower_http::cors::CorsLayer;
|
||||
|
||||
pub mod hello_world {
|
||||
tonic::include_proto!("helloworld");
|
||||
@@ -41,13 +39,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
Server::builder()
|
||||
// GrpcWeb is over http1 so we must enable it.
|
||||
.accept_http1(true)
|
||||
// Use the Cors layer from `tower-http`.
|
||||
.layer(CorsLayer::new())
|
||||
// Apply the tonic-web layer to convert
|
||||
// http1 requests into something that
|
||||
// the core tonic code can understand.
|
||||
.layer(GrpcWebLayer::new())
|
||||
.add_service(greeter)
|
||||
.add_service(tonic_web::enable(greeter))
|
||||
.serve(addr)
|
||||
.await?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user