Initial Commit

This commit is contained in:
2021-01-31 00:39:30 +01:00
commit 6085860bc6
10 changed files with 2732 additions and 0 deletions

36
src/main.rs Normal file
View File

@ -0,0 +1,36 @@
mod health;
mod routes;
use dotenv::dotenv;
use health::HealthState;
use rocket_contrib::serve::StaticFiles;
use rocket_contrib::templates::Template;
use std::sync::Arc;
use std::{env, io};
use tokio::fs;
#[rocket::main]
async fn main() -> io::Result<()> {
dotenv().ok();
let config_path = env::var("CONFIG_PATH").unwrap_or("config.ron".into());
let config = fs::read_to_string(&config_path)
.await
.expect("failed to read config file");
let config = ron::from_str(&config).expect("failed to parse config file");
let state = HealthState::new(config);
let rocket = rocket::ignite()
//.attach(Template::custom(|engines| {
//handlebars_util::register_helpers(engines)
//}))
.manage(Arc::new(state))
.mount("/static", StaticFiles::from("static"))
.mount("/", rocket::routes![routes::pages::index,]);
//.register(rocket::catchers![auth::login_page,]);
rocket.launch().await.expect("rocket failed to launch");
Ok(())
}