feat(web): Implement tower::Layer for tonic_web::Config (#1119)

Signed-off-by: slinkydeveloper <[email protected]>
This commit is contained in:
Francesco Guardiani
2022-10-28 13:59:01 -04:00
committed by GitHub
parent b409ddd478
commit 40536dc134
5 changed files with 47 additions and 6 deletions
+4 -3
View File
@@ -88,17 +88,18 @@
#![doc(issue_tracker_base_url = "https://github.com/hyperium/tonic/issues/")]
pub use config::Config;
pub use layer::GrpcWebLayer;
pub use service::GrpcWeb;
mod call;
mod config;
mod cors;
mod layer;
mod service;
use crate::service::GrpcWeb;
use std::future::Future;
use std::pin::Pin;
use tonic::body::BoxBody;
use tonic::transport::NamedService;
use tower_service::Service;
/// enable a tonic service to handle grpc-web requests with the default configuration.
@@ -107,7 +108,7 @@ use tower_service::Service;
pub fn enable<S>(service: S) -> GrpcWeb<S>
where
S: Service<http::Request<hyper::Body>, Response = http::Response<BoxBody>>,
S: NamedService + Clone + Send + 'static,
S: Clone + Send + 'static,
S::Future: Send + 'static,
S::Error: Into<BoxError> + Send,
{