Skip to content

Commit

Permalink
Remove tonic-web custom cors implementation and replace it with tower…
Browse files Browse the repository at this point in the history
…-http `CorsLayer`. Fix hyperium#1122

Signed-off-by: slinkydeveloper <[email protected]>
  • Loading branch information
slinkydeveloper committed Oct 31, 2022
1 parent 14b93c0 commit e916469
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 835 deletions.
5 changes: 2 additions & 3 deletions examples/src/grpc-web/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use tonic::{transport::Server, Request, Response, Status};

use hello_world::greeter_server::{Greeter, GreeterServer};
use hello_world::{HelloReply, HelloRequest};
use tonic_web::GrpcWebLayer;

pub mod hello_world {
tonic::include_proto!("helloworld");
Expand Down Expand Up @@ -33,14 +34,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {

let greeter = MyGreeter::default();
let greeter = GreeterServer::new(greeter);
let greeter = tonic_web::config()
.allow_origins(vec!["127.0.0.1"])
.enable(greeter);

println!("GreeterServer listening on {}", addr);

Server::builder()
.accept_http1(true)
.layer(GrpcWebLayer::new())
.add_service(greeter)
.serve(addr)
.await?;
Expand Down
1 change: 1 addition & 0 deletions tonic-web/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pin-project = "1"
tonic = {version = "0.8", path = "../tonic", default-features = false, features = ["transport"]}
tower-service = "0.3"
tower-layer = "0.3"
tower-http = { version = "0.3", features = ["cors"] }
tracing = "0.1"

[dev-dependencies]
Expand Down
166 changes: 0 additions & 166 deletions tonic-web/src/config.rs

This file was deleted.

Loading

0 comments on commit e916469

Please sign in to comment.