mirror of https://github.com/raftario/filite.git
ID conversion route
This commit is contained in:
parent
8d6bdc20c1
commit
93b211f743
|
@ -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))
|
||||
|
|
|
@ -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::{
|
||||
|
|
Loading…
Reference in New Issue