diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs index e283b21..f97f600 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,12 +1,18 @@ #![feature(proc_macro_hygiene, decl_macro)] -use rocket::{get, routes}; +use rocket::{get, http::RawStr, routes, response::NamedFile}; +use std::path::PathBuf; #[get("/")] fn index() -> &'static str { "Holahey, Jävlar!" } +#[get("/<file>", rank = 99)] +fn public_file(file: &RawStr) -> Option<NamedFile> { + NamedFile::open(PathBuf::from("public/").join(file.as_str())).ok() +} + fn main() { - rocket::ignite().mount("/", routes![index]).launch(); + rocket::ignite().mount("/", routes![index, public_file]).launch(); } |