Update tonic-web to v0.5.0.

This commit is contained in:
Orne Brocaar 2023-01-11 12:38:05 +00:00
parent a2a0d59982
commit 10371e66a2
3 changed files with 31 additions and 35 deletions

6
Cargo.lock generated
View File

@ -4121,9 +4121,9 @@ dependencies = [
[[package]]
name = "tonic-web"
version = "0.4.0"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e392f7556972523aa87ddb0fc7f2d2ce530559956706aa081bb0bd8fed158559"
checksum = "9213351ad53b0dcf1c9cf7c372a47533446b1114928a9177bedc6c551e14b7cf"
dependencies = [
"base64",
"bytes",
@ -4133,6 +4133,8 @@ dependencies = [
"hyper",
"pin-project",
"tonic",
"tower-http",
"tower-layer",
"tower-service",
"tracing",
]

View File

@ -58,7 +58,7 @@ rdkafka = { version = "0.28", features = ["cmake-build"]}
# gRPC and Protobuf
tonic = "0.8"
tonic-web = "0.4"
tonic-web = "0.5"
tonic-reflection = "0.5"
tokio = { version = "1.23", features = ["macros", "rt-multi-thread"] }
tokio-stream = "0.1"

View File

@ -19,6 +19,7 @@ use tokio::{task, try_join};
use tonic::transport::Server as TonicServer;
use tonic::Code;
use tonic_reflection::server::Builder as TonicReflectionBuilder;
use tonic_web::GrpcWebLayer;
use tower::{Service, ServiceBuilder};
use tower_http::trace::TraceLayer;
use tracing::{error, info};
@ -102,60 +103,53 @@ pub async fn setup() -> Result<()> {
// tonic gRPC service
let tonic_service = TonicServer::builder()
.accept_http1(true)
.layer(GrpcWebLayer::new())
.add_service(
TonicReflectionBuilder::configure()
.register_encoded_file_descriptor_set(chirpstack_api::api::DESCRIPTOR)
.build()
.unwrap(),
)
.add_service(tonic_web::enable(InternalServiceServer::with_interceptor(
.add_service(InternalServiceServer::with_interceptor(
internal::Internal::new(
validator::RequestValidator::new(),
conf.api.secret.clone(),
),
auth::auth_interceptor,
)))
.add_service(tonic_web::enable(
ApplicationServiceServer::with_interceptor(
application::Application::new(validator::RequestValidator::new()),
auth::auth_interceptor,
),
))
.add_service(tonic_web::enable(
DeviceProfileServiceServer::with_interceptor(
device_profile::DeviceProfile::new(validator::RequestValidator::new()),
auth::auth_interceptor,
),
.add_service(ApplicationServiceServer::with_interceptor(
application::Application::new(validator::RequestValidator::new()),
auth::auth_interceptor,
))
.add_service(tonic_web::enable(
DeviceProfileTemplateServiceServer::with_interceptor(
device_profile_template::DeviceProfileTemplate::new(
validator::RequestValidator::new(),
),
auth::auth_interceptor,
),
.add_service(DeviceProfileServiceServer::with_interceptor(
device_profile::DeviceProfile::new(validator::RequestValidator::new()),
auth::auth_interceptor,
))
.add_service(tonic_web::enable(TenantServiceServer::with_interceptor(
.add_service(DeviceProfileTemplateServiceServer::with_interceptor(
device_profile_template::DeviceProfileTemplate::new(
validator::RequestValidator::new(),
),
auth::auth_interceptor,
))
.add_service(TenantServiceServer::with_interceptor(
tenant::Tenant::new(validator::RequestValidator::new()),
auth::auth_interceptor,
)))
.add_service(tonic_web::enable(DeviceServiceServer::with_interceptor(
))
.add_service(DeviceServiceServer::with_interceptor(
device::Device::new(validator::RequestValidator::new()),
auth::auth_interceptor,
)))
.add_service(tonic_web::enable(UserServiceServer::with_interceptor(
))
.add_service(UserServiceServer::with_interceptor(
user::User::new(validator::RequestValidator::new()),
auth::auth_interceptor,
)))
.add_service(tonic_web::enable(GatewayServiceServer::with_interceptor(
))
.add_service(GatewayServiceServer::with_interceptor(
gateway::Gateway::new(validator::RequestValidator::new()),
auth::auth_interceptor,
)))
.add_service(tonic_web::enable(
MulticastGroupServiceServer::with_interceptor(
multicast::MulticastGroup::new(validator::RequestValidator::new()),
auth::auth_interceptor,
),
))
.add_service(MulticastGroupServiceServer::with_interceptor(
multicast::MulticastGroup::new(validator::RequestValidator::new()),
auth::auth_interceptor,
))
.into_service();
let mut tonic_service = ServiceBuilder::new()