aboutsummaryrefslogtreecommitdiffstats
path: root/src/controllers/home_controller.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/controllers/home_controller.rs')
-rw-r--r--src/controllers/home_controller.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/controllers/home_controller.rs b/src/controllers/home_controller.rs
index 563be40..6423a30 100644
--- a/src/controllers/home_controller.rs
+++ b/src/controllers/home_controller.rs
@@ -1,5 +1,7 @@
use ::{models, utils};
+use rocket;
use rocket_contrib::Json;
+use std::path::PathBuf;
#[derive(BartDisplay, Serialize)]
#[template = "templates/index.html"]
@@ -23,3 +25,11 @@ fn index(conn: utils::DbConn) -> utils::Page<IndexTemplate> {
fn index_json(conn: utils::DbConn) -> Json<Vec<models::Post>> {
Json(models::Post::get_all(conn))
}
+
+//
+// Serve files from the public directory if no routes matches.
+//
+#[get("/<file..>", rank = 99)]
+fn public_file(file: PathBuf) -> Option<rocket::response::NamedFile> {
+ rocket::response::NamedFile::open(PathBuf::from("public/").join(file)).ok()
+}