mirror of
https://github.com/flibusta-apps/book_bot.git
synced 2025-12-06 15:35:35 +01:00
Fix for reuse connections
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
use once_cell::sync::Lazy;
|
||||
use smallvec::SmallVec;
|
||||
use smartstring::alias::String as SmartString;
|
||||
|
||||
@@ -5,6 +6,10 @@ use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::config;
|
||||
|
||||
|
||||
pub static CLIENT: Lazy<reqwest::Client> = Lazy::new(reqwest::Client::new);
|
||||
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum TaskObjectType {
|
||||
@@ -43,7 +48,7 @@ pub struct Task {
|
||||
pub async fn create_task(
|
||||
data: CreateTaskData,
|
||||
) -> Result<Task, Box<dyn std::error::Error + Send + Sync>> {
|
||||
Ok(reqwest::Client::new()
|
||||
Ok(CLIENT
|
||||
.post(format!("{}/api/", &config::CONFIG.batch_downloader_url))
|
||||
.body(serde_json::to_string(&data).unwrap())
|
||||
.header("Authorization", &config::CONFIG.batch_downloader_api_key)
|
||||
@@ -56,7 +61,7 @@ pub async fn create_task(
|
||||
}
|
||||
|
||||
pub async fn get_task(task_id: String) -> Result<Task, Box<dyn std::error::Error + Send + Sync>> {
|
||||
Ok(reqwest::Client::new()
|
||||
Ok(CLIENT
|
||||
.get(format!(
|
||||
"{}/api/check_archive/{task_id}",
|
||||
&config::CONFIG.batch_downloader_url
|
||||
|
||||
Reference in New Issue
Block a user