main now matches against dotenv return val

main also returns a Result<(), i32>
This commit is contained in:
shockrah 2020-02-05 16:30:50 -08:00
parent 03b111c4dd
commit c5461f16ad

View File

@ -1,21 +1,30 @@
// This client code really just serves as the url router for the main website where we describe what the project is about
#![feature(proc_macro_hygiene, decl_macro, plugin)]
//#[macro_use] extern crate serde_derive;
#[macro_use] extern crate serde_derive;
#[macro_use] extern crate rocket;
extern crate rocket_contrib;
#[macro_use] extern crate rocket_contrib;
#[macro_use] extern crate diesel;
extern crate chrono;
extern crate dotenv;
extern crate serde;
use rocket_contrib::serve::StaticFiles;
use rocket_contrib::templates::Template;
use dotenv::dotenv;
use std::env::var;
mod website;
use website::*;
mod schema;
mod invites;
mod models;
use website::*;
use invites::*;
#[database("freechat_sample_db")]
pub struct DBConn(diesel::MysqlConnection);
fn rocket() -> rocket::Rocket {
rocket::ignite()
.mount("/static", StaticFiles::from("/static"))
@ -27,11 +36,21 @@ fn rocket() -> rocket::Rocket {
generate_invite, use_invite
])
.attach(Template::fairing())
.attach(DBConn::fairing())
}
fn main() {
website::init();
fn main() -> Result<(), i32> {
let dot = dotenv();
match dot {
Ok(d) => {
println!("Got .env: {}", var("DATABASE_URL").unwrap());
rocket().launch();
},
Err(e) => {
panic!("`.env` Could not be loaded err: {:?}", e);
}
}
Ok(())
}
// Integrating some basic tests just for this module