use super::http_client::{HttpClient, HttpResponse};
pub struct UreqClient;
impl HttpClient for UreqClient {
fn get(&self, url: &str, headers: &[(&str, &str)]) -> anyhow::Result<HttpResponse> {
let mut req = ureq::get(url);
for &(name, value) in headers {
req = req.set(name, value);
}
let resp = req
.call()
.map_err(|e| anyhow::anyhow!("HTTP request failed: {e}"))?;
let status = resp.status();
let body = resp
.into_string()
.map_err(|e| anyhow::anyhow!("failed to read response body: {e}"))?;
Ok(HttpResponse { status, body })
}
}