contraband 0.1.2

Contraband is a web framework for building modular and scalable applications
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//! Helpers for loading module configuration
fn get_prop_str(section: &str, property: &str) -> Option<String> {
    std::env::var(format!(
        "{}__{}",
        section.to_uppercase(),
        property.to_uppercase()
    ))
    .ok()
}

pub fn get_prop<T: std::str::FromStr>(section: &str, property: &str) -> Option<T> {
    let val = get_prop_str(section, property).map(|x| x.parse::<T>());
    match val {
        Some(Ok(val)) => Some(val),
        _ => None,
    }
}