diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2018-07-31 15:14:44 +0200 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2018-07-31 15:14:44 +0200 |
commit | 6e5801a75399f7b8bc7adb1b19bc2d26e169f970 (patch) | |
tree | cd5f6fda4d6b8c85dba9f81a989ca9330d3b302c /src/controllers | |
parent | f90641a4bce63797434228c32c72db879dbeef58 (diff) | |
download | rocket-blog-6e5801a75399f7b8bc7adb1b19bc2d26e169f970.tar.gz rocket-blog-6e5801a75399f7b8bc7adb1b19bc2d26e169f970.tar.bz2 rocket-blog-6e5801a75399f7b8bc7adb1b19bc2d26e169f970.zip |
Move routing details into controllers.
Diffstat (limited to 'src/controllers')
-rw-r--r-- | src/controllers/home_controller.rs | 8 | ||||
-rw-r--r-- | src/controllers/login_controller.rs | 4 | ||||
-rw-r--r-- | src/controllers/posts_controller.rs | 12 | ||||
-rw-r--r-- | src/controllers/users_controller.rs | 5 |
4 files changed, 29 insertions, 0 deletions
diff --git a/src/controllers/home_controller.rs b/src/controllers/home_controller.rs index 2f657c3..bef47de 100644 --- a/src/controllers/home_controller.rs +++ b/src/controllers/home_controller.rs @@ -37,3 +37,11 @@ fn index_json(conn: utils::DbConn) -> Json<Vec<models::Post>> { fn public_file(file: PathBuf) -> Option<rocket::response::NamedFile> { rocket::response::NamedFile::open(PathBuf::from("public/").join(file)).ok() } + +pub fn routes() -> Vec<rocket::Route> { + routes![ + index, + index_json, + public_file + ] +} diff --git a/src/controllers/login_controller.rs b/src/controllers/login_controller.rs index 35841b3..800a6b2 100644 --- a/src/controllers/login_controller.rs +++ b/src/controllers/login_controller.rs @@ -36,3 +36,7 @@ pub fn create(login: Form<LoginForm>, conn: utils::DbConn) -> Flash<Redirect> { Flash::error(Redirect::to("/login"), "Invalid email or passoword!") } + +pub fn routes() -> Vec<rocket::Route> { + routes![new, create] +} diff --git a/src/controllers/posts_controller.rs b/src/controllers/posts_controller.rs index aca9d13..f10f312 100644 --- a/src/controllers/posts_controller.rs +++ b/src/controllers/posts_controller.rs @@ -1,4 +1,5 @@ use comrak::{markdown_to_html, ComrakOptions}; +use rocket; use rocket::request::Form; use rocket::response::{Flash, Redirect}; use utils; @@ -83,3 +84,14 @@ fn delete(id: i32, conn: utils::DbConn) -> Flash<Redirect> { ::models::Post::delete(id, conn); Flash::success(Redirect::to("/"), "Post deleted!") } + +pub fn routes() -> Vec<rocket::Route> { + routes![ + new, + create, + show, + edit, + update, + delete + ] +} diff --git a/src/controllers/users_controller.rs b/src/controllers/users_controller.rs index 8dcd4c0..9708a1b 100644 --- a/src/controllers/users_controller.rs +++ b/src/controllers/users_controller.rs @@ -1,3 +1,4 @@ +use rocket; use rocket::request::Form; use rocket::response::{Flash, Redirect}; use utils; @@ -38,3 +39,7 @@ fn create(user: Form<::models::NewUser>, conn: utils::DbConn) -> Flash<Redirect> Err(_) => Flash::error(Redirect::to("/"), "Could not create user!") } } + +pub fn routes() -> Vec<rocket::Route> { + routes![new, create] +} |