fix: fix dotenv loader inconsistent and many ui issues
This commit is contained in:
@@ -176,7 +176,7 @@ impl HttpClient {
|
||||
let accept_invalid_certs = proxy
|
||||
.accept_invalid_certs
|
||||
.as_ref()
|
||||
.map(|b| b.as_bool())
|
||||
.map(|b| *b)
|
||||
.unwrap_or_default();
|
||||
let proxy = proxy.clone().into_proxy()?;
|
||||
if let Some(proxy) = proxy {
|
||||
@@ -307,7 +307,7 @@ impl HttpClient {
|
||||
let accept_invalid_certs = proxy
|
||||
.accept_invalid_certs
|
||||
.as_ref()
|
||||
.map(|b| b.as_bool())
|
||||
.map(|b| *b)
|
||||
.unwrap_or_default();
|
||||
let proxy = proxy.clone().into_proxy().unwrap_or_default();
|
||||
if let Some(proxy) = proxy {
|
||||
|
||||
@@ -2,22 +2,24 @@ use axum::http::{HeaderMap, HeaderValue};
|
||||
use reqwest::{NoProxy, Proxy};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_with::{NoneAsEmptyString, serde_as};
|
||||
use util::BooleanLike;
|
||||
|
||||
use crate::HttpClientError;
|
||||
|
||||
#[serde_as]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct HttpClientProxyConfig {
|
||||
#[serde(default)]
|
||||
#[serde_as(as = "NoneAsEmptyString")]
|
||||
pub server: Option<String>,
|
||||
#[serde(default)]
|
||||
#[serde_as(as = "NoneAsEmptyString")]
|
||||
pub auth_header: Option<String>,
|
||||
#[serde(with = "http_serde::option::header_map")]
|
||||
pub headers: Option<HeaderMap>,
|
||||
#[serde(default)]
|
||||
#[serde_as(as = "NoneAsEmptyString")]
|
||||
pub no_proxy: Option<String>,
|
||||
pub accept_invalid_certs: Option<BooleanLike>,
|
||||
pub accept_invalid_certs: Option<bool>,
|
||||
}
|
||||
|
||||
impl HttpClientProxyConfig {
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
pub mod errors;
|
||||
pub mod loose;
|
||||
|
||||
pub use errors::OptDynErr;
|
||||
pub use loose::BooleanLike;
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum BooleanLike {
|
||||
Boolean(bool),
|
||||
String(String),
|
||||
Number(i32),
|
||||
}
|
||||
|
||||
impl BooleanLike {
|
||||
pub fn as_bool(&self) -> bool {
|
||||
match self {
|
||||
BooleanLike::Boolean(b) => *b,
|
||||
BooleanLike::String(s) => s.to_lowercase() == "true",
|
||||
BooleanLike::Number(n) => *n != 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user