rfc/api/mod.rs
1mod datatracker;
2mod rfc_editor;
3
4use std::time::Duration;
5
6use anyhow::{Context, Result};
7use reqwest::Client;
8
9pub use datatracker::{DataTrackerClient, DATATRACKER_BASE_URL};
10pub use rfc_editor::DocumentFetcher;
11
12/// Build the shared HTTP client used by every API wrapper.
13///
14/// All callers want the same user-agent and timeout, so creating a fresh
15/// `reqwest::Client` per call would just rebuild the connection pool.
16pub fn build_http_client() -> Result<Client> {
17 Client::builder()
18 .user_agent(concat!("rfc-cli/", env!("CARGO_PKG_VERSION")))
19 .timeout(Duration::from_secs(30))
20 .build()
21 .context("Failed to create HTTP client")
22}