Skip to content

Remove tonic-web custom cors implementation and replace it with tower-http CorsLayer #1123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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