better project structure
This commit is contained in:
13
src/shared/settings.rs
Normal file
13
src/shared/settings.rs
Normal file
@@ -0,0 +1,13 @@
|
||||
//! 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())
|
||||
}
|
||||
Reference in New Issue
Block a user