various: shared HTTP client with connection pooling
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: Id13c17e9352da970a289f4e3ad909c5b6a6a6964
This commit is contained in:
parent
0d64d4d1de
commit
0e5fd41496
6 changed files with 64 additions and 20 deletions
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue