conduit_cli/modrinth/
client.rs1use reqwest::header::{HeaderMap, HeaderValue, USER_AGENT};
2
3pub struct ModrinthAPI {
4 pub(super) client: reqwest::Client,
5 pub(super) base_url: String,
6}
7
8impl ModrinthAPI {
9 pub fn new() -> Self {
10 let mut headers = HeaderMap::new();
11 headers.insert(USER_AGENT, HeaderValue::from_static("Conduit-CLI"));
12
13 let client = reqwest::Client::builder()
14 .default_headers(headers)
15 .build()
16 .expect("Failed to create HTTP client");
17
18 Self {
19 client,
20 base_url: "https://api.modrinth.com/v2".to_string(),
21 }
22 }
23}
24
25impl Default for ModrinthAPI {
26 fn default() -> Self {
27 Self::new()
28 }
29}