Commit 4e7e920 1 parent 7c3f798 commit 4e7e920 Copy full SHA for 4e7e920
File tree 1 file changed +7
-2
lines changed
1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change 4
4
//!
5
5
//! - They are harder to maintain.
6
6
//! - They introduce new attack vectors.
7
+ use std:: time:: Duration ;
7
8
use std:: { env, process} ;
8
9
10
+ use reqwest:: Client ;
11
+
9
12
#[ tokio:: main]
10
13
async fn main ( ) {
11
14
let args: Vec < String > = env:: args ( ) . collect ( ) ;
12
15
if args. len ( ) != 2 {
13
16
eprintln ! ( "Usage: cargo run --bin health_check <HEALTH_URL>" ) ;
14
- eprintln ! ( "Example: cargo run --bin health_check http://localhost:3002 /health_check" ) ;
17
+ eprintln ! ( "Example: cargo run --bin health_check http://127.0.0.1:3001 /health_check" ) ;
15
18
std:: process:: exit ( 1 ) ;
16
19
}
17
20
18
21
println ! ( "Health check ..." ) ;
19
22
20
23
let url = & args[ 1 ] . clone ( ) ;
21
24
22
- match reqwest:: get ( url) . await {
25
+ let client = Client :: builder ( ) . timeout ( Duration :: from_secs ( 5 ) ) . build ( ) . unwrap ( ) ;
26
+
27
+ match client. get ( url) . send ( ) . await {
23
28
Ok ( response) => {
24
29
if response. status ( ) . is_success ( ) {
25
30
println ! ( "STATUS: {}" , response. status( ) ) ;
You can’t perform that action at this time.
0 commit comments