Skip to content

Commit

Permalink
Use 'StaticFiles' in todo example.
Browse files Browse the repository at this point in the history
  • Loading branch information
SergioBenitez committed Aug 24, 2018
1 parent 2821711 commit cb18954
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 12 deletions.
2 changes: 1 addition & 1 deletion examples/todo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ rand = "0.5"
[dependencies.rocket_contrib]
path = "../../contrib/lib"
default_features = false
features = ["tera_templates", "diesel_sqlite_pool"]
features = ["tera_templates", "diesel_sqlite_pool", "static_files"]
7 changes: 3 additions & 4 deletions examples/todo/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@
#[macro_use] extern crate serde_derive;
extern crate rocket_contrib;

mod static_files;
mod task;
#[cfg(test)] mod tests;

use rocket::Rocket;
use rocket::request::{Form, FlashMessage};
use rocket::response::{Flash, Redirect};
use rocket_contrib::Template;
use rocket_contrib::databases::database;
use rocket_contrib::{Template, databases::database, static_files::StaticFiles};
use diesel::SqliteConnection;

use task::{Task, Todo};
Expand Down Expand Up @@ -76,7 +74,8 @@ fn index(msg: Option<FlashMessage>, conn: DbConn) -> Template {
fn rocket() -> (Rocket, Option<DbConn>) {
let rocket = rocket::ignite()
.attach(DbConn::fairing())
.mount("/", routes![index, static_files::all])
.mount("/", StaticFiles::from("static/"))
.mount("/", routes![index])
.mount("/todo", routes![new, toggle, delete])
.attach(Template::fairing());

Expand Down
7 changes: 0 additions & 7 deletions examples/todo/src/static_files.rs

This file was deleted.

0 comments on commit cb18954

Please sign in to comment.