Skip to main content

fnox_core/
http.rs

1use std::time::Duration;
2
3/// Build an HTTP client with the configured timeout from settings.
4pub fn http_client() -> reqwest::Client {
5    let settings = crate::settings::Settings::get();
6    let timeout =
7        crate::lease::parse_duration(&settings.http_timeout).unwrap_or(Duration::from_secs(30));
8    let user_agent = format!("fnox/{}", env!("CARGO_PKG_VERSION"));
9    reqwest::Client::builder()
10        .timeout(timeout)
11        .user_agent(user_agent)
12        .build()
13        .unwrap_or_else(|e| {
14            tracing::warn!(
15                "Failed to build HTTP client with timeout: {e}; using default (no timeout)"
16            );
17            reqwest::Client::new()
18        })
19}