comment_app_backend/
lib.rs

1// lib.rs
2// commenting tool related functions are implemented here
3
4use std::collections::HashMap;
5use lazy_static::*;
6use config::{Config, File, FileFormat};
7
8mod db;
9pub mod log;
10pub mod models;
11pub mod filters;
12pub mod handlers;
13pub mod utils;
14pub mod comment_server;
15
16// Initialize: templates and settings
17lazy_static!{
18    static ref SETTINGS: HashMap<String, String> = get_settings();
19}
20
21// extract commenting specific settings from Settings.toml
22fn get_settings() -> HashMap<String, String> {
23    let mut config = Config::default();
24    config.merge(File::new("Settings", FileFormat::Toml)).unwrap();
25    let settings = config.try_into::<HashMap<String, String>>().unwrap(); // Deserialize entire file
26    settings
27}
28
29pub fn config(key: &str) -> String {
30    SETTINGS.get(key).unwrap().to_string()
31}