1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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
}
}