diff --git a/src/main.rs b/src/main.rs index 2a13af0..37582b4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -57,6 +57,7 @@ async fn main() { .route("/", web::get().to(routes::index)) .route("/logout", web::get().to(routes::logout)) .route("/config", web::get().to(routes::get_config)) + .route("/id/{id}", web::get().to(routes::id_to_str)) .service( web::resource("/f") .route(web::get().to(routes::files::select)) diff --git a/src/routes.rs b/src/routes.rs index d066ec2..07c0af8 100644 --- a/src/routes.rs +++ b/src/routes.rs @@ -252,6 +252,14 @@ pub async fn logout(identity: Identity) -> impl Responder { } } +pub async fn id_to_str(path: web::Path) -> impl Responder { + let id: i32 = match path.parse() { + Ok(id) => id, + Err(_) => return Err(HttpResponse::BadRequest().body("Invalid ID")), + }; + Ok(HttpResponse::Ok().body(radix_fmt::radix_36(id).to_string())) +} + pub mod files { use crate::routes::match_replace_result; use crate::{