diff options
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("/") } |