add version + arch api
This commit is contained in:
parent
6449f9c1f1
commit
2544143809
1 changed files with 14 additions and 3 deletions
|
@ -14,10 +14,21 @@ use serde_json::json;
|
||||||
use super::take_out;
|
use super::take_out;
|
||||||
|
|
||||||
/// Package API Endpoint
|
/// Package API Endpoint
|
||||||
#[get("/json/pkg/<repo>/<pkg_name>")]
|
#[get("/json/pkg/<repo>/<pkg_name>?<ver>&<arch>")]
|
||||||
pub async fn pkg_json(repo: &str, pkg_name: &str) -> serde_json::Value {
|
pub async fn pkg_json(repo: &str, pkg_name: &str, ver: Option<&str>, arch: Option<&str>) -> serde_json::Value {
|
||||||
let repository = Repository::new(repo).unwrap();
|
let repository = Repository::new(repo).unwrap();
|
||||||
let pkg = repository.get_pkg_by_name(pkg_name).unwrap();
|
let mut pkg = repository.get_pkg_by_name(pkg_name).unwrap();
|
||||||
|
|
||||||
|
if let Some(ver) = ver {
|
||||||
|
let (version, rel) = Package::version(ver);
|
||||||
|
pkg = pkg.get_version(&version);
|
||||||
|
pkg.rel = rel;
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(arch) = arch {
|
||||||
|
let arch = Architecture::parse(arch).unwrap();
|
||||||
|
pkg = pkg.switch_arch(arch);
|
||||||
|
}
|
||||||
|
|
||||||
let versions = pkg.versions();
|
let versions = pkg.versions();
|
||||||
let version = pkg.version.clone();
|
let version = pkg.version.clone();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue