api
This commit is contained in:
parent
67033785ad
commit
e6362f69a7
8 changed files with 79 additions and 13 deletions
|
@ -6,10 +6,33 @@ use pacco::pkg::package::PackageMetaInfo;
|
|||
use rocket::{State, get};
|
||||
|
||||
use pacco::pkg::{Repository, arch::Architecture};
|
||||
use serde_json::json;
|
||||
|
||||
use crate::routes::ui::arch_card;
|
||||
use pacco::config::Config;
|
||||
|
||||
/// Repository API Endpoint
|
||||
#[get("/<repo>/<arch>/json")]
|
||||
pub async fn repo_arch_json(
|
||||
repo: &str,
|
||||
ctx: RequestContext,
|
||||
arch: &str,
|
||||
config: &State<Config>,
|
||||
) -> serde_json::Value {
|
||||
let arch = Architecture::parse(arch).unwrap_or(Architecture::any);
|
||||
let repo_name = repo;
|
||||
|
||||
let repo = Repository::new(repo_name).unwrap();
|
||||
let packages = repo.list_pkg_arch(arch.clone());
|
||||
|
||||
json!({
|
||||
"repo": repo_name,
|
||||
"arch": arch.to_string(),
|
||||
"packages": packages
|
||||
})
|
||||
}
|
||||
|
||||
/// Repository Overview UI
|
||||
#[get("/<repo>?<arch>&<sort>")]
|
||||
pub async fn repo_ui(
|
||||
repo: &str,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue