From 3e2b1525e951837cf2dbe486f27ae121e8b1b262 Mon Sep 17 00:00:00 2001 From: Jose Celano Date: Tue, 16 Jan 2024 09:16:17 +0000 Subject: [PATCH] feat: [#604] add timeout to http_health_check binary --- src/bin/http_health_check.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/bin/http_health_check.rs b/src/bin/http_health_check.rs index d66d334d..b7c6dfa4 100644 --- a/src/bin/http_health_check.rs +++ b/src/bin/http_health_check.rs @@ -4,8 +4,11 @@ //! //! - They are harder to maintain. //! - They introduce new attack vectors. +use std::time::Duration; use std::{env, process}; +use reqwest::Client; + #[tokio::main] async fn main() { let args: Vec = env::args().collect(); @@ -19,7 +22,9 @@ async fn main() { let url = &args[1].clone(); - match reqwest::get(url).await { + let client = Client::builder().timeout(Duration::from_secs(5)).build().unwrap(); + + match client.get(url).send().await { Ok(response) => { if response.status().is_success() { println!("STATUS: {}", response.status());