|
|
@@ -6,13 +6,14 @@ pub const GITEA_API_URL: &str = "https://git.exmods.org/api/v1"; |
|
|
|
// API endpoints |
|
|
|
pub fn get_releases(owner: &str, repo: &str) -> Result<Vec<Release>, String> { |
|
|
|
let client = blocking::Client::new(); |
|
|
|
let url = format!("{}/{}/{}/releases", GITEA_API_URL, owner, repo); |
|
|
|
let url = format!("{}/repos/{}/{}/releases", GITEA_API_URL, owner, repo); |
|
|
|
let result = client.get(&url).send(); |
|
|
|
if let Ok(resp) = result { |
|
|
|
if let Ok(data) = resp.json::<Vec<Release>>() { |
|
|
|
let result = resp.json::<Vec<Release>>(); |
|
|
|
if let Ok(data) = result { |
|
|
|
return Ok(data); |
|
|
|
} else { |
|
|
|
return Err("Invalid JSON payload".to_string()); |
|
|
|
return Err(format!("Invalid JSON payload {}", result.err().unwrap())); |
|
|
|
} |
|
|
|
} |
|
|
|
Err("Invalid Result".to_string()) |
|
|
|