various: shared HTTP client with connection pooling

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: Id13c17e9352da970a289f4e3ad909c5b6a6a6964
This commit is contained in:
raf 2026-02-18 17:20:29 +03:00
commit 0e5fd41496
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
6 changed files with 64 additions and 20 deletions

View file

@ -1,4 +1,4 @@
use std::collections::HashMap;
use std::{collections::HashMap, sync::Arc};
use async_trait::async_trait;
use reqwest::Client;
@ -20,18 +20,22 @@ const LOADER_VERSION_TYPE_ID: i32 = 68441;
const DEPENDENCY_RELATION_TYPE_REQUIRED: u32 = 3;
pub struct CurseForgePlatform {
client: Client,
client: Arc<Client>,
api_key: Option<String>,
}
impl CurseForgePlatform {
pub fn new(api_key: Option<String>) -> Self {
Self {
client: Client::new(),
client: Arc::new(Client::new()),
api_key,
}
}
pub fn with_client(client: Arc<Client>, api_key: Option<String>) -> Self {
Self { client, api_key }
}
fn get_headers(&self) -> Result<reqwest::header::HeaderMap> {
let mut headers = reqwest::header::HeaderMap::new();