Reorganizing files
This commit is contained in:
parent
1c4077ffc3
commit
883a0669fe
11 changed files with 105 additions and 45 deletions
25
src/api/endpoints.rs
Normal file
25
src/api/endpoints.rs
Normal 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)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue