From 87f6876120a21253792869f511a40d0072383d5a Mon Sep 17 00:00:00 2001 From: Daiki Mizukami Date: Wed, 18 Dec 2019 13:36:29 +0900 Subject: [PATCH] feat(client): impl tower_service::Service for &Client --- src/client/mod.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/client/mod.rs b/src/client/mod.rs index 71b2046e8b..a64970fe99 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -562,6 +562,26 @@ where } } +impl tower_service::Service> for &'_ Client +where + C: Connect + Clone + Send + Sync + 'static, + B: HttpBody + Send + 'static, + B::Data: Send, + B::Error: Into>, +{ + type Response = Response; + type Error = crate::Error; + type Future = ResponseFuture; + + fn poll_ready(&mut self, _: &mut task::Context<'_>) -> Poll> { + Poll::Ready(Ok(())) + } + + fn call(&mut self, req: Request) -> Self::Future { + self.request(req) + } +} + impl Clone for Client { fn clone(&self) -> Client { Client {