aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2018-01-11 22:41:09 +0100
committerHarald Eilertsen <haraldei@anduin.net>2018-01-11 22:41:09 +0100
commit22bac37fcaa1b1cdf8755754184ec8b3ace313b1 (patch)
tree41e6b4ec69b173313c257d9c74b8e62fce6028b1 /src/main.rs
parent757770635c4c2537b03f9b1fb1576a8bf4609a72 (diff)
downloadrocket-blog-22bac37fcaa1b1cdf8755754184ec8b3ace313b1.tar.gz
rocket-blog-22bac37fcaa1b1cdf8755754184ec8b3ace313b1.tar.bz2
rocket-blog-22bac37fcaa1b1cdf8755754184ec8b3ace313b1.zip
Drop the lib.
The misc stuff from the lib root was moved to the utils module (terrible name, it's meant to be temporary.) The modules under the lib has been moved directly under the app.
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/main.rs b/src/main.rs
index 5084fbc..109d7d1 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,17 +1,22 @@
-#![feature(plugin)]
+#![feature(plugin, custom_derive)]
#![plugin(rocket_codegen)]
-#[macro_use] extern crate rocket_blog;
#[macro_use] extern crate bart_derive;
+#[macro_use] extern crate diesel_codegen;
+#[macro_use] extern crate diesel;
#[macro_use] extern crate serde_derive;
-extern crate diesel;
+extern crate dotenv;
+extern crate r2d2;
+extern crate r2d2_diesel;
extern crate rocket;
extern crate rocket_contrib;
-use rocket_blog::models;
use rocket_contrib::Json;
+#[macro_use] mod utils;
+mod models;
+mod schema;
mod posts;
#[derive(BartDisplay, Serialize)]
@@ -24,18 +29,18 @@ struct IndexTemplate<'a> {
implement_responder_for!(IndexTemplate<'a>);
#[get("/", format = "text/html")]
-fn index<'a>(conn: rocket_blog::DbConn) -> IndexTemplate<'a> {
+fn index<'a>(conn: utils::DbConn) -> IndexTemplate<'a> {
IndexTemplate { title: "Bloggen", posts: models::Post::get_all(conn) }
}
#[get("/", format = "application/json")]
-fn index_json(conn: rocket_blog::DbConn) -> Json<Vec<models::Post>> {
+fn index_json(conn: utils::DbConn) -> Json<Vec<models::Post>> {
Json(models::Post::get_all(conn))
}
fn main() {
rocket::ignite()
- .manage(rocket_blog::init_db_pool())
+ .manage(utils::init_db_pool())
.mount("/", routes![index, index_json])
.mount("/posts", routes![posts::new, posts::create, posts::show, posts::edit, posts::update])
.launch();