From 97190d913f3349b637e8adca4d9d9d113ff27971 Mon Sep 17 00:00:00 2001 From: "Wyatt J. Miller" Date: Sun, 10 Nov 2024 16:41:37 -0500 Subject: [PATCH] added client certs to request struct --- src/util/request.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/util/request.rs b/src/util/request.rs index 16f4d4f..ad1352d 100644 --- a/src/util/request.rs +++ b/src/util/request.rs @@ -1,6 +1,8 @@ use reqwest::StatusCode; +use std::time::Duration; pub struct Request<'a> { + pub client: reqwest::Client, pub base_url: &'a str, pub full_url: Option<&'a str>, } @@ -8,6 +10,11 @@ pub struct Request<'a> { impl<'a> Request<'a> { pub fn new() -> Self { Request { + client: reqwest::ClientBuilder::new() + .use_rustls_tls() + .timeout(Duration::from_secs(30)) + .build() + .unwrap(), base_url: "https://site.api.espn.com/apis/site/v2/sports/football", full_url: None, } @@ -26,7 +33,7 @@ impl<'a> Request<'a> { T: for<'de> serde::Deserialize<'de>, { println!("{}", url); - let api_result = match reqwest::get(url).await { + let api_result = match self.client.get(url).send().await { Ok(r) => r, Err(e) => return Err(Box::new(e)), };