Update rest-grpc-multiplex example to include reflection (#1902)

This commit is contained in:
David Pedersen
2023-04-01 20:49:36 +02:00
committed by GitHub
parent 0096fa6e1e
commit 24f8dc53f4
4 changed files with 26 additions and 8 deletions
+11 -1
View File
@@ -18,6 +18,9 @@ mod multiplex_service;
mod proto {
tonic::include_proto!("helloworld");
pub(crate) const FILE_DESCRIPTOR_SET: &[u8] =
tonic::include_file_descriptor_set!("helloworld_descriptor");
}
#[derive(Default)]
@@ -58,7 +61,14 @@ async fn main() {
let rest = Router::new().route("/", get(web_root));
// build the grpc service
let grpc = GreeterServer::new(GrpcServiceImpl::default());
let reflection_service = tonic_reflection::server::Builder::configure()
.register_encoded_file_descriptor_set(proto::FILE_DESCRIPTOR_SET)
.build()
.unwrap();
let grpc = tonic::transport::Server::builder()
.add_service(reflection_service)
.add_service(GreeterServer::new(GrpcServiceImpl::default()))
.into_service();
// combine them into one service
let service = MultiplexService::new(rest, grpc);