mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-29 00:00:18 +02:00
Update rest-grpc-multiplex example to include reflection (#1902)
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user