From 0aca77375fc10e5967d0d0aa67feb275d5261297 Mon Sep 17 00:00:00 2001 From: Joachim Lusiardi Date: Thu, 8 Feb 2024 15:13:05 +0100 Subject: [PATCH] use 5s timeout for get request --- src/main.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 36966d3..7554700 100644 --- a/src/main.rs +++ b/src/main.rs @@ -45,6 +45,11 @@ async fn main() -> Result<(), Box> { let mut write_queries: Vec = Vec::new(); + let http_client = reqwest::Client::builder() + .timeout(core::time::Duration::from_secs(5)) + .build() + .unwrap(); + if let Some(configs) = config_data["configs"].as_array() { for config in configs { let mut handlebars = Handlebars::new(); @@ -54,7 +59,9 @@ async fn main() -> Result<(), Box> { let url = handlebars.render("url", &data).unwrap(); println!("URL: {}", url); - let response_json: serde_json::Value = reqwest::get(url) + let response_json: serde_json::Value = http_client + .get(url) + .send() .await? .json() .await?;