From 54d7a7af6b6530b80353c5741586c38cca8382c9 Mon Sep 17 00:00:00 2001 From: Sherlock Holo Date: Wed, 17 Jun 2020 06:22:12 +0800 Subject: [PATCH] feat: add new method get_uri for Endpoint (#371) --- tonic/src/transport/channel/endpoint.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tonic/src/transport/channel/endpoint.rs b/tonic/src/transport/channel/endpoint.rs index f9c6e76..346fa27 100644 --- a/tonic/src/transport/channel/endpoint.rs +++ b/tonic/src/transport/channel/endpoint.rs @@ -226,6 +226,19 @@ impl Endpoint { Channel::connect(connector, self.clone()).await } + + /// Get the endpoint uri. + /// + /// ``` + /// # use tonic::transport::Endpoint; + /// # use http::Uri; + /// let endpoint = Endpoint::from_static("https://example.com"); + /// + /// assert_eq!(endpoint.get_uri(), &Uri::from_static("https://example.com")); + /// ``` + pub fn get_uri(&self) -> &Uri { + &self.uri + } } impl From for Endpoint {