refactor code and add dragover visual cue

Signed-off-by: Gunwant Jain <mail@wantguns.dev>
This commit is contained in:
Gunwant Jain
2021-12-26 08:23:18 +05:30
parent a9dc9452fc
commit cca3a8bec9
6 changed files with 271 additions and 230 deletions

View File

@@ -1,7 +1,10 @@
use std::path::{Path, PathBuf};
use rocket::fs::NamedFile;
use rocket::response::status::NotFound;
use std::path::{Path, PathBuf};
#[get("/<file..>", rank = 3)]
pub async fn static_files(file: PathBuf) -> Option<NamedFile> {
NamedFile::open(Path::new("static/").join(file)).await.ok()
pub async fn static_files(file: PathBuf) -> Result<NamedFile, NotFound<String>> {
NamedFile::open(Path::new("static/").join(file))
.await
.map_err(|e| NotFound(e.to_string()))
}