ID conversion route

This commit is contained in:
Raphaël Thériault 2020-03-09 15:22:13 -04:00
parent 8d6bdc20c1
commit 93b211f743
2 changed files with 9 additions and 0 deletions

View File

@ -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))

View File

@ -252,6 +252,14 @@ pub async fn logout(identity: Identity) -> impl Responder {
}
}
pub async fn id_to_str(path: web::Path<String>) -> 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::{