use std::time::Duration;
use reqwest::header::HeaderMap;
pub const DEFAULT_REQUEST_TIMEOUT_SECS: u64 = 120;
pub const DEFAULT_CONNECT_TIMEOUT_SECS: u64 = 15;
pub fn build_client(headers: HeaderMap) -> reqwest::Client {
reqwest::Client::builder()
.default_headers(headers)
.timeout(Duration::from_secs(DEFAULT_REQUEST_TIMEOUT_SECS))
.connect_timeout(Duration::from_secs(DEFAULT_CONNECT_TIMEOUT_SECS))
.build()
.expect("reqwest client build failed")
}
pub fn build_client_with_timeout(
headers: HeaderMap,
request_timeout_secs: u64,
connect_timeout_secs: u64,
) -> reqwest::Client {
reqwest::Client::builder()
.default_headers(headers)
.timeout(Duration::from_secs(request_timeout_secs))
.connect_timeout(Duration::from_secs(connect_timeout_secs))
.build()
.expect("reqwest client build failed")
}