20 lines
781 B
Rust
20 lines
781 B
Rust
use std::collections::HashMap;
|
|
|
|
use actix_web::{get, post, web, Responder};
|
|
|
|
use crate::storage::IStorage;
|
|
|
|
#[get("/stats")]
|
|
pub async fn decky_statistics(data: actix_web::web::Data<Box<dyn IStorage>>) -> impl Responder {
|
|
let plugins: HashMap<String, u64> = data.get_statistics();
|
|
web::Json(plugins)
|
|
}
|
|
|
|
|
|
#[post("/plugins/{name}/versions/{version}")]
|
|
pub async fn decky_statistics_increment(data: actix_web::web::Data<Box<dyn IStorage>>, path: actix_web::web::Path<(String, String)>, query: actix_web::web::Query<decky_api::StorePluginIncrement>) -> actix_web::Result<impl Responder> {
|
|
let new_version_info = data.increment_statistic(&path.0, &path.1, &*query)
|
|
.map_err(|e| actix_web::error::ErrorNotFound(e.to_string()))?;
|
|
Ok(web::Json(new_version_info))
|
|
}
|