aboutsummaryrefslogtreecommitdiffstats
path: root/src/posts.rs
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2017-12-23 16:48:25 +0100
committerHarald Eilertsen <haraldei@anduin.net>2017-12-23 16:48:25 +0100
commitf91bc37b14ec958f67e217ffa65cdf98b8f7417d (patch)
tree9ee7a51249e71629311127605ed3148db5cbe580 /src/posts.rs
parente5b5a9dc28401815f8e9a68007281d23b3f52825 (diff)
downloadrocket-blog-f91bc37b14ec958f67e217ffa65cdf98b8f7417d.tar.gz
rocket-blog-f91bc37b14ec958f67e217ffa65cdf98b8f7417d.tar.bz2
rocket-blog-f91bc37b14ec958f67e217ffa65cdf98b8f7417d.zip
Implement posts/show handler.
Diffstat (limited to 'src/posts.rs')
-rw-r--r--src/posts.rs14
1 files changed, 14 insertions, 0 deletions
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("/<id>", format = "text/html")]
+fn show<'a>(id: i32, conn: ::rocket_blog::DbConn) -> ShowPostTemplate {
+ let p = ::models::Post::get(id, conn);
+ ShowPostTemplate { post: p }
+}