mirror of
https://codeberg.org/YGGverse/psocks.git
synced 2026-03-31 16:35:28 +00:00
implement cache/clean api
This commit is contained in:
parent
0603fdf4a6
commit
461f838cc0
4 changed files with 35 additions and 3 deletions
12
src/main.rs
12
src/main.rs
|
|
@ -56,6 +56,16 @@ async fn api_block(
|
|||
})?))
|
||||
}
|
||||
|
||||
#[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;
|
||||
info!("Clean cache file: {result:?}");
|
||||
Ok(Json(result.map_err(|e| {
|
||||
error!("Could not handle cache clean request: `{e}`");
|
||||
Status::InternalServerError
|
||||
})?))
|
||||
}
|
||||
|
||||
#[rocket::launch]
|
||||
async fn rocket() -> _ {
|
||||
env_logger::init();
|
||||
|
|
@ -91,7 +101,7 @@ async fn rocket() -> _ {
|
|||
.manage(Instant::now())
|
||||
.mount(
|
||||
"/",
|
||||
rocket::routes![index, api_totals, api_allow, api_block],
|
||||
rocket::routes![index, api_totals, api_allow, api_block, api_cache_clean],
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue