Initial Commit
This commit is contained in:
36
src/main.rs
Normal file
36
src/main.rs
Normal 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(())
|
||||
}
|
||||
Reference in New Issue
Block a user