feat: add GrpcMethod extension into request for client (#1275)
* feat: add GrpcMethod extension into request for client * refactor: change GrpcMethod fields into private and expose methods instead * refactor: hide GrpcMethod::new in doc --------- Co-authored-by: Lucio Franco <[email protected]>
This commit is contained in:
co-authored by
Lucio Franco
parent
1547f968b4
commit
7a6b20d8ef
@@ -11,6 +11,7 @@ pub use std::task::{Context, Poll};
|
||||
pub use tower_service::Service;
|
||||
pub type StdError = Box<dyn std::error::Error + Send + Sync + 'static>;
|
||||
pub use crate::codec::{CompressionEncoding, EnabledCompressionEncodings};
|
||||
pub use crate::extensions::GrpcMethod;
|
||||
pub use crate::service::interceptor::InterceptedService;
|
||||
pub use bytes::Bytes;
|
||||
pub use http;
|
||||
|
||||
@@ -71,3 +71,27 @@ impl fmt::Debug for Extensions {
|
||||
f.debug_struct("Extensions").finish()
|
||||
}
|
||||
}
|
||||
|
||||
/// A gRPC Method info extension.
|
||||
#[derive(Debug)]
|
||||
pub struct GrpcMethod {
|
||||
service: &'static str,
|
||||
method: &'static str,
|
||||
}
|
||||
|
||||
impl GrpcMethod {
|
||||
/// Create a new `GrpcMethod` extension.
|
||||
#[doc(hidden)]
|
||||
pub fn new(service: &'static str, method: &'static str) -> Self {
|
||||
Self { service, method }
|
||||
}
|
||||
|
||||
/// gRPC service name
|
||||
pub fn service(&self) -> &str {
|
||||
&self.service
|
||||
}
|
||||
/// gRPC method name
|
||||
pub fn method(&self) -> &str {
|
||||
&self.method
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -111,7 +111,7 @@ pub use async_trait::async_trait;
|
||||
|
||||
#[doc(inline)]
|
||||
pub use codec::Streaming;
|
||||
pub use extensions::Extensions;
|
||||
pub use extensions::{Extensions, GrpcMethod};
|
||||
pub use request::{IntoRequest, IntoStreamingRequest, Request};
|
||||
pub use response::Response;
|
||||
pub use status::{Code, Status};
|
||||
|
||||
Reference in New Issue
Block a user