From 5fc79d351f2bfef1ac79416e8c35237994867045 Mon Sep 17 00:00:00 2001 From: Arthur Silva Date: Tue, 13 Dec 2022 14:21:15 +0100 Subject: [PATCH] Add hyper_builder field to Config --- CHANGELOG.md | 1 + Cargo.toml | 2 +- src/lib.rs | 7 ++++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 56eff7e..c357184 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## Unreleased ### Added +- `hyper_builder` field was added to `Config` in order to allow specifying additional hyper options. - `default-tls`, `rustls-native`, and `rustls-webpki` features to allow usage of rustls for the https client ### Changed ### Deprecated diff --git a/Cargo.toml b/Cargo.toml index bfa27c6..b2ffa5e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ futures = "0.3.8" http = "0.2.1" hyper = { version = "0.14.2", features = ["full"] } hyper-rustls = { version = "0.22.1", optional = true } -hyper-tls = { version = "0.5.0", optional = true, no-default-features = true } +hyper-tls = { version = "0.5.0", optional = true, default-features = true } lazy_static = { version = "1.4.0", optional = true } opentelemetry = { version = "0.15", features = ["tokio", "rt-tokio"] } prometheus = { version = "0.13", optional = true } diff --git a/src/lib.rs b/src/lib.rs index 2540c82..15d0ff5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -150,6 +150,10 @@ pub struct Config { pub address: String, /// The consul secret token to make authenticated requests to the consul server. pub token: Option, + + /// The hyper builder for the internal http client. + #[serde(skip)] + pub hyper_builder: hyper::client::Builder, } impl Config { @@ -165,6 +169,7 @@ impl Config { Config { address: addr, token: Some(token), + hyper_builder: Default::default(), } } } @@ -233,7 +238,7 @@ impl Consul { /// - [Config](consul::Config) pub fn new(config: Config) -> Self { let https = https_client(); - let https_client = hyper::Client::builder().build::<_, hyper::Body>(https); + let https_client = config.hyper_builder.build::<_, hyper::Body>(https); Consul { https_client, config,