From f09e8e56921361b406e40eddd6ded9daca9dc8a5 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Thu, 16 Nov 2017 21:28:11 +0100 Subject: Set correct content-type for response. --- src/main.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index 55131fc..e0501d0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,6 +8,7 @@ extern crate rocket_blog; use self::diesel::prelude::*; use self::rocket_blog::{schema, models}; +use rocket::response; #[derive(BartDisplay)] #[template = "templates/index.html"] @@ -17,14 +18,14 @@ struct IndexTemplate<'a> { } #[get("/")] -fn index(conn: rocket_blog::DbConn) -> String { +fn index(conn: rocket_blog::DbConn) -> content::Html { use schema::posts::dsl::*; let results = posts.filter(published.eq(false)) .limit(5) .load::(&*conn) .expect("Error loading posts"); - format!("{}", &IndexTemplate{ title: "Bloggen", posts: results }) + content::Html(format!("{}", &IndexTemplate{ title: "Bloggen", posts: results })) } fn main() { -- cgit v1.2.3