headless_lms_utils/
http.rs

1use once_cell::sync::Lazy;
2use std::env;
3
4pub static REQWEST_CLIENT: Lazy<reqwest::Client> = Lazy::new(|| {
5    // if ApplicationConfiguration was static these env var fetches wouldn't
6    // need to be made...
7    let http_test_mode: bool = env::var("USE_MOCK_AZURE_CONFIGURATION")
8        .is_ok_and(|v| v.as_str() != "false")
9        && env::var("TEST_MODE").is_ok();
10    if http_test_mode {
11        warn!("Test environment. REQWEST_CLIENT is allowed to make http requests");
12    }
13
14    reqwest::Client::builder()
15        .use_rustls_tls()
16        .https_only(!http_test_mode)
17        .build()
18        .expect("Failed to build Client")
19});