From f91bc37b14ec958f67e217ffa65cdf98b8f7417d Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Sat, 23 Dec 2017 16:48:25 +0100 Subject: Implement posts/show handler. --- src/posts.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/posts.rs') diff --git a/src/posts.rs b/src/posts.rs index 350ab53..a9cbcf1 100644 --- a/src/posts.rs +++ b/src/posts.rs @@ -27,3 +27,17 @@ fn create(post: Form<::models::NewPost>, conn: ::rocket_blog::DbConn) -> Redirec Redirect::to("/") } + +#[derive(BartDisplay)] +#[template = "templates/show_post.html"] +pub struct ShowPostTemplate { + post: ::models::Post +} + +implement_responder_for!(ShowPostTemplate); + +#[get("/", format = "text/html")] +fn show<'a>(id: i32, conn: ::rocket_blog::DbConn) -> ShowPostTemplate { + let p = ::models::Post::get(id, conn); + ShowPostTemplate { post: p } +} -- cgit v1.2.3