diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2018-01-11 22:41:09 +0100 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2018-01-11 22:41:09 +0100 |
commit | 22bac37fcaa1b1cdf8755754184ec8b3ace313b1 (patch) | |
tree | 41e6b4ec69b173313c257d9c74b8e62fce6028b1 /src/posts.rs | |
parent | 757770635c4c2537b03f9b1fb1576a8bf4609a72 (diff) | |
download | rocket-blog-22bac37fcaa1b1cdf8755754184ec8b3ace313b1.tar.gz rocket-blog-22bac37fcaa1b1cdf8755754184ec8b3ace313b1.tar.bz2 rocket-blog-22bac37fcaa1b1cdf8755754184ec8b3ace313b1.zip |
Drop the lib.
The misc stuff from the lib root was moved to the utils module (terrible
name, it's meant to be temporary.) The modules under the lib has been
moved directly under the app.
Diffstat (limited to 'src/posts.rs')
-rw-r--r-- | src/posts.rs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/posts.rs b/src/posts.rs index 859cce5..fde08a8 100644 --- a/src/posts.rs +++ b/src/posts.rs @@ -1,5 +1,6 @@ use rocket::request::Form; use rocket::response::Redirect; +use utils; #[derive(BartDisplay)] #[template = "templates/new_post.html"] @@ -11,12 +12,12 @@ pub struct NewPostTemplate<'a> { implement_responder_for!(NewPostTemplate<'a>); #[get("/new", format = "text/html")] -fn new<'a>(_conn: ::rocket_blog::DbConn) -> NewPostTemplate<'a> { +fn new<'a>(_conn: utils::DbConn) -> NewPostTemplate<'a> { NewPostTemplate { title: "Bloggen", post: Default::default() } } #[post("/create", data="<post>")] -fn create(post: Form<::models::NewPost>, conn: ::rocket_blog::DbConn) -> Redirect { +fn create(post: Form<::models::NewPost>, conn: utils::DbConn) -> Redirect { ::models::Post::create(post.get(), conn); Redirect::to("/") } @@ -30,7 +31,7 @@ pub struct ShowPostTemplate { implement_responder_for!(ShowPostTemplate); #[get("/<id>", format = "text/html")] -fn show<'a>(id: i32, conn: ::rocket_blog::DbConn) -> ShowPostTemplate { +fn show<'a>(id: i32, conn: utils::DbConn) -> ShowPostTemplate { let p = ::models::Post::get(id, conn); ShowPostTemplate { post: p } } @@ -44,13 +45,13 @@ pub struct EditPostTemplate { implement_responder_for!(EditPostTemplate); #[get("/<id>/edit", format = "text/html")] -fn edit(id: i32, conn: ::rocket_blog::DbConn) -> EditPostTemplate { +fn edit(id: i32, conn: utils::DbConn) -> EditPostTemplate { let p = ::models::Post::get(id, conn); EditPostTemplate { post: p } } #[post("/update", data="<post>")] -fn update(post: Form<::models::Post>, conn: ::rocket_blog::DbConn) -> Redirect { +fn update(post: Form<::models::Post>, conn: utils::DbConn) -> Redirect { ::models::Post::update(post.get(), conn); Redirect::to("/") } |