Reorganizing files

This commit is contained in:
Marco De Araujo 2025-12-23 08:57:20 -04:00
parent 1c4077ffc3
commit 883a0669fe
11 changed files with 105 additions and 45 deletions

25
src/api/endpoints.rs Normal file
View file

@ -0,0 +1,25 @@
use url::Url;
#[derive(Debug, Clone)]
pub struct UptimeKumaEndpoints {
base_url: Url,
slug: String,
}
impl UptimeKumaEndpoints {
pub fn new(base_url: &str, slug: &str) -> Result<Self, url::ParseError> {
let base_url = Url::parse(base_url.trim_end_matches("/"))?;
Ok(Self {
base_url,
slug: slug.to_string(),
})
}
pub fn heartbeat_url(&self) -> String {
format!("{}api/status-page/heartbeat/{}", self.base_url, self.slug)
}
pub fn status_page_url(&self) -> String {
format!("{}api/status-page/{}", self.base_url, self.slug)
}
}