implement (rules) list api

This commit is contained in:
postscriptum 2026-03-23 09:00:19 +02:00
parent 461f838cc0
commit eeafed077a
4 changed files with 34 additions and 1 deletions

View file

@ -56,6 +56,13 @@ async fn api_block(
})?))
}
#[rocket::get("/api/list")]
async fn api_list(list: &State<Arc<List>>) -> Result<Json<Vec<String>>, Status> {
let result = list.list().await;
info!("Get list rules (total: {})", result.len());
Ok(Json(result))
}
#[rocket::get("/api/cache/clean")]
async fn api_cache_clean(list: &State<Arc<List>>) -> Result<Json<Option<Vec<String>>>, Status> {
let result = list.cache_clean().await;
@ -101,7 +108,14 @@ async fn rocket() -> _ {
.manage(Instant::now())
.mount(
"/",
rocket::routes![index, api_totals, api_allow, api_block, api_cache_clean],
rocket::routes![
index,
api_totals,
api_allow,
api_block,
api_list,
api_cache_clean
],
)
}