added client certs to request struct
All checks were successful
build / docker (push) Successful in 12m3s
All checks were successful
build / docker (push) Successful in 12m3s
This commit is contained in:
parent
8f00d4ec4c
commit
97190d913f
@ -1,6 +1,8 @@
|
|||||||
use reqwest::StatusCode;
|
use reqwest::StatusCode;
|
||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
pub struct Request<'a> {
|
pub struct Request<'a> {
|
||||||
|
pub client: reqwest::Client,
|
||||||
pub base_url: &'a str,
|
pub base_url: &'a str,
|
||||||
pub full_url: Option<&'a str>,
|
pub full_url: Option<&'a str>,
|
||||||
}
|
}
|
||||||
@ -8,6 +10,11 @@ pub struct Request<'a> {
|
|||||||
impl<'a> Request<'a> {
|
impl<'a> Request<'a> {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Request {
|
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",
|
base_url: "https://site.api.espn.com/apis/site/v2/sports/football",
|
||||||
full_url: None,
|
full_url: None,
|
||||||
}
|
}
|
||||||
@ -26,7 +33,7 @@ impl<'a> Request<'a> {
|
|||||||
T: for<'de> serde::Deserialize<'de>,
|
T: for<'de> serde::Deserialize<'de>,
|
||||||
{
|
{
|
||||||
println!("{}", url);
|
println!("{}", url);
|
||||||
let api_result = match reqwest::get(url).await {
|
let api_result = match self.client.get(url).send().await {
|
||||||
Ok(r) => r,
|
Ok(r) => r,
|
||||||
Err(e) => return Err(Box::new(e)),
|
Err(e) => return Err(Box::new(e)),
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user