From 0bba55e85cd1fc6e77c1ddebe76f6e39c4aa2320 Mon Sep 17 00:00:00 2001 From: Nathan Shaaban Date: Mon, 4 Oct 2021 07:55:18 -0700 Subject: [PATCH 1/3] exposes surf's with_http_client --- influxdb/src/client/mod.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/influxdb/src/client/mod.rs b/influxdb/src/client/mod.rs index 41ac198..3ec59b9 100644 --- a/influxdb/src/client/mod.rs +++ b/influxdb/src/client/mod.rs @@ -20,7 +20,7 @@ use http::StatusCode; #[cfg(feature = "reqwest")] use reqwest::{Client as HttpClient, Response as HttpResponse}; #[cfg(feature = "surf")] -use surf::{Client as HttpClient, Response as HttpResponse}; +use surf::{Client as HttpClient, HttpClient as SurfHttpClient, Response as HttpResponse}; use crate::query::QueryType; use crate::Error; @@ -91,6 +91,13 @@ impl Client { self } + /// Allows creation of custom http clients + #[cfg(feature = "surf")] + pub fn with_http_client(mut self, http_client: T) -> Self { + self.client = HttpClient::with_http_client(http_client); + self + } + /// Returns the name of the database the client is using pub fn database_name(&self) -> &str { // safe to unwrap: we always set the database name in `Self::new` From bcc481c9e309159ae021a1e57c00932f5147c51b Mon Sep 17 00:00:00 2001 From: Nathan Shaaban Date: Mon, 4 Oct 2021 08:15:25 -0700 Subject: [PATCH 2/3] client-agnostic with_http_client --- influxdb/src/client/mod.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/influxdb/src/client/mod.rs b/influxdb/src/client/mod.rs index 3ec59b9..1c84b97 100644 --- a/influxdb/src/client/mod.rs +++ b/influxdb/src/client/mod.rs @@ -20,7 +20,7 @@ use http::StatusCode; #[cfg(feature = "reqwest")] use reqwest::{Client as HttpClient, Response as HttpResponse}; #[cfg(feature = "surf")] -use surf::{Client as HttpClient, HttpClient as SurfHttpClient, Response as HttpResponse}; +use surf::{Client as HttpClient, Response as HttpResponse}; use crate::query::QueryType; use crate::Error; @@ -91,10 +91,9 @@ impl Client { self } - /// Allows creation of custom http clients - #[cfg(feature = "surf")] - pub fn with_http_client(mut self, http_client: T) -> Self { - self.client = HttpClient::with_http_client(http_client); + /// Replaces the HTTP Client + pub fn with_http_client(mut self, http_client: HttpClient) -> Self { + self.client = http_client; self } From 67c1f41fddfcfb7a79dd89531b5e6c767aed1486 Mon Sep 17 00:00:00 2001 From: Dominic Date: Wed, 13 Oct 2021 17:26:01 +0200 Subject: [PATCH 3/3] trigger ci