From 77c3b5bc0c0d58ecd9f3c004287f65b8a94cc429 Mon Sep 17 00:00:00 2001 From: Daiki Mizukami Date: Fri, 26 Jun 2020 00:18:05 +0900 Subject: [PATCH] feat(client): impl tower_service::Service for &Client (#2089) --- 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 {