aboutsummaryrefslogblamecommitdiffstats
path: root/src/main.rs
blob: 4515a2d47c47a0eb864783ab18204103797255a1 (plain) (tree)
1
2
3
4
5
6
7
8
                                  

                          
                                      
                                 
                                       
 
                    


                         


                            


                       
                





                     
 
           


                                                    



                                                        




                                                                                              
 
#![feature(plugin, custom_derive)]
#![plugin(rocket_codegen)]

#[macro_use] extern crate bart_derive;
#[macro_use] extern crate diesel;
#[macro_use] extern crate serde_derive;

extern crate comrak;
extern crate dotenv;
extern crate r2d2;
extern crate r2d2_diesel;
extern crate rocket;
extern crate rocket_contrib;

#[macro_use] mod utils;
mod models;
mod schema;
mod controllers;
use controllers::{
    home_controller,
    login_controller,
    posts_controller,
    users_controller
};

fn main() {
    if let Ok(dburl) = dotenv::var("DATABASE_URL") {
        rocket::ignite()
            .manage(utils::init_db_pool(&dburl))
            .mount("/", home_controller::routes())
            .mount("/posts", posts_controller::routes())
            .mount("/users", users_controller::routes())
            .mount("/login", login_controller::routes())
            .launch();
    }
    else {
        eprintln!("Error: No database specified, make sure the DATABASE_URL env var is set.");
    };
}