add ability to create a client with own tls connector (#809)

This commit is contained in:
Nick Lanham
2020-02-21 11:39:31 -08:00
committed by GitHub
parent b3d5f78b8f
commit 9ab8ab945c
5 changed files with 155 additions and 3 deletions

View File

@@ -1,3 +1,4 @@
use std::any::Any;
use std::convert::TryInto;
use std::fmt;
use std::future::Future;
@@ -450,6 +451,15 @@ impl ClientBuilder {
self.with_inner(move |inner| inner.use_rustls_tls())
}
/// Use a preconfigured TLS backend.
///
/// If the passed `Any` argument is not a TLS backend that reqwest
/// understands, the `ClientBuilder` will error when calling `build`.
#[cfg(feature = "__tls")]
pub fn use_preconfigured_tls(self, tls: impl Any) -> ClientBuilder {
self.with_inner(move |inner| inner.use_preconfigured_tls(tls))
}
// private
fn with_inner<F>(mut self, func: F) -> ClientBuilder