//! Typed access to the free-form `settings.*` map from the loaded config.

use loco_rs::prelude::*;

/// Look up a string-valued `settings.<key>` entry, returning `None` if config
/// has no settings map, the key is missing, or the value is not a string.
pub fn get<'a>(ctx: &'a AppContext, key: &str) -> Option<&'a str> {
    ctx.config
        .settings
        .as_ref()
        .and_then(|settings| settings.get(key))
        .and_then(|value| value.as_str())
}
