Skip to content

Commit f9309fa

Browse files
committed
fix: Update settings to use Option<url::Url> for req_proxy and add url dependency
1 parent 9c7c6c5 commit f9309fa

3 files changed

Lines changed: 8 additions & 5 deletions

File tree

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ prost = "0.14"
2828
hudsucker = "0.23"
2929
const_format = "0.2"
3030
rand = "0.9"
31+
url = { version = "2", features = ["serde"] }
3132

3233
[build-dependencies]
3334
prost-build = "0.14"

src/settings.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub struct Settings {
2626
liqi_version: String,
2727
github_token: String,
2828
#[serde(default)]
29-
req_proxy: String,
29+
req_proxy: Option<url::Url>,
3030
#[serde(skip)]
3131
methods_set: HashSet<String>,
3232
#[serde(skip)]
@@ -50,13 +50,13 @@ static REQUEST_CLIENT: LazyLock<reqwest::Client> = LazyLock::new(|| {
5050
impl Settings {
5151
fn create_github_client(&self) -> Result<reqwest::Client> {
5252
let mut builder = reqwest::Client::builder().user_agent(APP_USER_AGENT);
53-
54-
if !self.req_proxy.is_empty() {
55-
let proxy = reqwest::Proxy::all(&self.req_proxy)
53+
54+
if let Some(req_proxy) = &self.req_proxy {
55+
let proxy = reqwest::Proxy::all(req_proxy.clone())
5656
.context("Failed to create proxy from req_proxy")?;
5757
builder = builder.proxy(proxy);
5858
}
59-
59+
6060
builder.build().context("Failed to build HTTP client")
6161
}
6262

0 commit comments

Comments
 (0)