use std::collections::HashMap;
pub struct RuntimeContext {
config: HashMap<String, String>,
}
impl RuntimeContext {
#[doc(hidden)]
pub fn with_environment(environment: &HashMap<String, String>) -> RuntimeContext {
const HEADER_PREFIX: &'static str = "fn_header_";
RuntimeContext {
config: environment
.iter()
.filter(|kv| !kv.0.to_lowercase().starts_with(HEADER_PREFIX))
.fold(HashMap::new(), |mut cfg, kv| {
cfg.insert(kv.0.clone(), kv.1.clone());
cfg
}),
}
}
pub fn config(&self) -> &HashMap<String, String> {
&self.config
}
}