feat(tonic-web): implement grpc <-> grpc-web protocol translation (#455)
tonic-web enables tonic servers to handle requests from grpc-web clients directly, without the need of an external proxy. Co-authored-by: John Hernandez <[email protected]> Co-authored-by: zancas <[email protected]>
This commit is contained in:
co-authored by
John Hernandez
zancas
parent
352b0f584b
commit
c309063254
@@ -0,0 +1,17 @@
|
||||
use interop::server::{EchoHeadersSvc, TestService, TestServiceServer};
|
||||
use tonic::transport::Server;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let addr = ([127, 0, 0, 1], 9999).into();
|
||||
let test_svc = TestServiceServer::new(TestService::default());
|
||||
let with_echo = EchoHeadersSvc::new(test_svc);
|
||||
|
||||
Server::builder()
|
||||
.accept_http1(true)
|
||||
.add_service(tonic_web::enable(with_echo))
|
||||
.serve(addr)
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user