Put all URLs under /api/

This commit is contained in:
2024-07-05 20:00:52 -07:00
parent 714e73aeb1
commit 5fc272054c
6 changed files with 26 additions and 18 deletions

View File

@@ -12,3 +12,24 @@ pub struct SearchResult {
#[derive(Serialize, Deserialize, Debug)]
pub struct Message {}
pub mod urls {
pub const MOUNT_POINT: &'static str = "/api";
pub fn cid_prefix(host: Option<&str>, cid: &str) -> String {
if let Some(host) = host {
format!("//{host}/api/cid/{cid}/")
} else {
format!("/api/cid/{cid}/")
}
}
pub fn download_attachment(host: Option<&str>, id: &str, idx: &str, filename: &str) -> String {
if let Some(host) = host {
format!(
"//{host}/api/download/attachment/{}/{}/{}",
id, idx, filename
)
} else {
format!("/api/download/attachment/{}/{}/{}", id, idx, filename)
}
}
}