use reqwest::Client;
use std::time::Duration;
#[derive(Clone)]
pub struct OAuth2Client {
client: Client,
}
impl OAuth2Client {
pub fn new() -> Self {
let client = Client::builder()
.timeout(Duration::from_secs(30))
.connect_timeout(Duration::from_secs(10))
.build()
.expect("Failed to build HTTP client");
Self { client }
}
pub fn client(&self) -> &Client {
&self.client
}
}
impl Default for OAuth2Client {
fn default() -> Self {
Self::new()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_client_creation() {
let client = OAuth2Client::new();
let _client_ref = client.client();
}
#[test]
fn test_client_default() {
let client = OAuth2Client::default();
let _client_ref = client.client();
}
}