aboutsummaryrefslogtreecommitdiffstats
path: root/src/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'src/controllers')
-rw-r--r--src/controllers/home_controller.rs8
-rw-r--r--src/controllers/login_controller.rs4
-rw-r--r--src/controllers/posts_controller.rs12
-rw-r--r--src/controllers/users_controller.rs5
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]
+}