axum_bootstrap/util/
http.rs

1use reqwest::Client;
2
3use crate::DynError;
4
5pub async fn init_http_client(http_proxy: &str) -> Result<Client, DynError> {
6    let client_builder = Client::builder().pool_max_idle_per_host(20);
7    if http_proxy.is_empty() {
8        Ok(client_builder.build()?)
9    } else {
10        Ok(client_builder.proxy(reqwest::Proxy::all(http_proxy)?).build()?)
11    }
12}