Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
yangjing committed Sep 11, 2024
1 parent f63c0d8 commit 137e38d
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions crates/ultimate-grpc/src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use futures::{Future, TryFutureExt};
use prost_types::FieldMask;
use tonic::{metadata::MetadataMap, service::RoutesBuilder, transport::Server, Status};
use tower_http::trace::TraceLayer;
use tower_http::{compression::CompressionLayer, trace::TraceLayer};
use ultimate::{
configuration::model::{GrpcConf, SecurityConf},
security::{jose::JwtPayload, SecurityUtils},
Expand All @@ -18,13 +18,12 @@ where
{
let grpc_addr = conf.server_addr.parse()?;

#[cfg(not(feature = "tonic-web"))]
let b = Server::builder();
let mut b = Server::builder().layer(CompressionLayer::new()).layer(TraceLayer::new_for_grpc());

#[cfg(feature = "tonic-web")]
let b = Server::builder().accept_http1(true).layer(tonic_web::GrpcWebLayer::new());
let mut b = b.accept_http1(true).layer(tonic_web::GrpcWebLayer::new());

let mut routes_builder = RoutesBuilder::default();

f(&mut routes_builder);

#[cfg(feature = "tonic-reflection")]
Expand All @@ -38,8 +37,7 @@ where

// let s = router.into_service();

let serve =
b.layer(TraceLayer::new_for_grpc()).add_routes(routes_builder.routes()).serve(grpc_addr).map_err(DataError::from);
let serve = b.add_routes(routes_builder.routes()).serve(grpc_addr).map_err(DataError::from);
Ok(serve)
}

Expand Down

0 comments on commit 137e38d

Please sign in to comment.