diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2019-03-04 14:08:48 +0100 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2019-03-04 14:08:48 +0100 |
commit | 73c100ca9621ff9cfa3ca665e14e997524d92160 (patch) | |
tree | 5c9b5eef7872df679b0f286a762d4ff84d5a9b58 /src | |
parent | 0ecf1bf482b1db5e1e1fe07a5b21a57c084deb4e (diff) | |
download | ramaskrik-social-73c100ca9621ff9cfa3ca665e14e997524d92160.tar.gz ramaskrik-social-73c100ca9621ff9cfa3ca665e14e997524d92160.tar.bz2 ramaskrik-social-73c100ca9621ff9cfa3ca665e14e997524d92160.zip |
Use rocket_contrib StaticFiles module to serve static files.
This also changes the structure of the app quite significantly. Instead
if generating the html for the index, we simply provide a public/index.html
static file instead. For now this seems to make sense, it may not hold in
the long run, but that's for another time to worry about.
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 29 |
1 files changed, 3 insertions, 26 deletions
diff --git a/src/main.rs b/src/main.rs index 1ee6011..5c858aa 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,31 +17,8 @@ */ #![feature(proc_macro_hygiene, decl_macro)] -use askama::Template; -use rocket::{ - get, - http::RawStr, - routes, - response::NamedFile, -}; -use std::path::PathBuf; - -#[derive(Template)] -#[template(path = "index.html")] -struct IndexTemplate<'a> { - year: &'a str, -} - -#[get("/")] -fn index<'a>() -> IndexTemplate<'static> { - IndexTemplate { year: "2019" } -} - -#[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, public_file]).launch(); + rocket::ignite() + .mount("/", rocket_contrib::serve::StaticFiles::from("./public")) + .launch(); } |