implement basic config

This commit is contained in:
glyph 2022-03-11 14:27:40 +02:00
parent 6b145d66f8
commit ec288658f3
2 changed files with 13 additions and 3 deletions

View File

@ -6,7 +6,7 @@ use std::io::{self, BufRead};
use std::path::Path;
// Ini-like key=value configuration with global config only (no subsections).
#[derive(Debug)]
#[derive(Debug, PartialEq)]
pub struct Config {
pub disable_auth: bool,
pub standalone_mode: bool,

View File

@ -13,9 +13,10 @@
//! CSS.
//mod context;
mod config;
pub mod error;
//mod router;
//pub mod routes;
mod routes;
//#[cfg(test)]
//mod tests;
mod templates;
@ -31,6 +32,8 @@ use log::info;
use rouille::{router, Response};
// crate-local dependencies
use config::Config;
use utils::Theme;
pub type BoxError = Box<dyn std::error::Error>;
@ -49,7 +52,10 @@ pub struct RocketConfig {
}
*/
static CONFIG_PATH: &str = "./config";
lazy_static! {
static ref CONFIG: Config = Config::from_file(CONFIG_PATH).expect("failed to read config file");
static ref THEME: RwLock<Theme> = RwLock::new(Theme::Light);
}
@ -119,7 +125,11 @@ fn main() {
router!(request,
(GET) (/) => {
Response::html(templates::home::build())
Response::html(routes::home::build())
},
(GET) (/settings) => {
Response::html(routes::settings::menu::build())
},
// The code block is called if none of the other blocks matches the request.