From dca28e3c44e5214d161cbe0ca179137b3efb310e Mon Sep 17 00:00:00 2001 From: "alex.berger@nexiot.ch" Date: Tue, 21 Jan 2020 20:16:58 +0100 Subject: [PATCH] Add support for passing preconfigured isahc HttpClient instance. --- src/isahc.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/isahc.rs b/src/isahc.rs index 37cd584..b2dd79b 100644 --- a/src/isahc.rs +++ b/src/isahc.rs @@ -21,8 +21,13 @@ impl Default for IsahcClient { impl IsahcClient { /// Create a new instance. pub fn new() -> Self { + Self::from_client(isahc::HttpClient::new().unwrap()) + } + + /// Create from externally initialized and configured client. + pub fn from_client(client: isahc::HttpClient) -> Self { Self { - client: Arc::new(isahc::HttpClient::new().unwrap()), + client: Arc::new(client), } } }