diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2019-03-02 22:39:53 +0100 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2019-03-02 22:39:53 +0100 |
commit | 50adf72a2391bbd840eb139a5f82e503530c65fb (patch) | |
tree | 19a43b8443982c9a3b264f25f07c7d7d3451bf25 /src | |
parent | 71eec22a16e0ac62bb2a04dbec535ff09411821d (diff) | |
download | ramaskrik-social-50adf72a2391bbd840eb139a5f82e503530c65fb.tar.gz ramaskrik-social-50adf72a2391bbd840eb139a5f82e503530c65fb.tar.bz2 ramaskrik-social-50adf72a2391bbd840eb139a5f82e503530c65fb.zip |
Add favicon and route to get public files.
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(); } |