todo_app_server 0.1.2

A Todo-app-server for learning purpose
Documentation
use std::collections::HashMap;
use lazy_static::*;
use config::{Config, File, FileFormat};

pub mod models;
pub mod filters;
pub mod handlers;
pub mod todo_server;
pub mod log;
pub mod db;

// initialize: application settings 
lazy_static!{
    // pull-in todo specific settings from Settings.toml 
    static ref SETTINGS: HashMap<String, String> = get_settings();
}

// Extract Todo Specific settings from Settings.toml
fn get_settings() -> HashMap<String, String> {
    let mut config = Config::default();
    config.merge(File::new("Settings", FileFormat::Toml)).unwrap();
    let settings = config.try_into::<HashMap<String, String>>().unwrap(); // Deserialize entire file contents
    settings
}

pub fn config(key: &str) -> String {
    SETTINGS.get(key).unwrap().to_string()
}