index: drag & drop redirects to the syntax highlighted pages
Signed-off-by: Gunwant Jain <mail@wantguns.dev>
This commit is contained in:
@@ -18,6 +18,7 @@ fn rocket() -> _ {
|
||||
routes::upload::upload,
|
||||
routes::submit::submit,
|
||||
routes::retrieve::retrieve,
|
||||
routes::retrieve::retrieve_ext,
|
||||
routes::pretty_retrieve::pretty_retrieve,
|
||||
routes::pretty_retrieve_ext::pretty_retrieve_ext
|
||||
],
|
||||
|
||||
@@ -1,10 +1,20 @@
|
||||
use std::fs::File;
|
||||
|
||||
use crate::models::pretty_syntax::PasteIdSyntax;
|
||||
use crate::models::paste_id::PasteId;
|
||||
|
||||
#[get("/<id>")]
|
||||
#[get("/<id>", rank = 2)]
|
||||
pub async fn retrieve(id: PasteId<'_>) -> Option<File> {
|
||||
let filename = format!("upload/{id}", id = id);
|
||||
|
||||
File::open(&filename).ok()
|
||||
}
|
||||
}
|
||||
|
||||
// rank 1 here because this would be more oftenly used
|
||||
#[get("/<id_ext>", rank = 1)]
|
||||
pub async fn retrieve_ext(id_ext: PasteIdSyntax<'_>) -> Option<File> {
|
||||
let filename = format!("upload/{id}", id = id_ext.get_fname());
|
||||
|
||||
File::open(&filename).ok()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user