diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 26 |
1 files changed, 1 insertions, 25 deletions
diff --git a/src/main.rs b/src/main.rs index f89a39f..0cf1acf 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,7 +3,7 @@ extern crate diesel; extern crate rocket; -extern crate rocket_blog; +#[macro_use] extern crate rocket_blog; extern crate rocket_contrib; #[macro_use] extern crate bart_derive; #[macro_use] extern crate serde_derive; @@ -11,10 +11,6 @@ extern crate rocket_contrib; use self::diesel::prelude::*; use self::rocket_blog::{schema, models}; use rocket_contrib::Json; -use rocket::response::{Response, Responder}; -use rocket::request::Request; -use rocket::http::{ContentType, Status}; -use std::io::Cursor; mod posts; @@ -25,27 +21,7 @@ struct IndexTemplate<'a> { posts: Vec<models::Post> } -macro_rules! implement_responder_for { - // Implement a responder for the given template type - // - // Seems I can't add the lifetime after the matcher, - // like this: `$template_type<'a>` - // So it will have to be passed in to the argument at - // the macro incovation instead. - ($template_type:ty) => ( - impl<'a> Responder<'a> for $template_type { - fn respond_to(self, _: &Request) -> Result<Response<'static>, Status> { - Response::build() - .header(ContentType::HTML) - .sized_body(Cursor::new(format!("{}", &self))) - .ok() - } - } - ) -} - implement_responder_for!(IndexTemplate<'a>); -implement_responder_for!(posts::NewPostTemplate<'a>); fn get_posts(conn: rocket_blog::DbConn) -> Vec<models::Post> { use schema::posts::dsl::*; |