#[merge_conf]
Expand description
This attribute macro merges the configuration settings from all structs identified as field of
the current struct. The result will implement serde::Deserialize
, Debug
and Default
automatically. All field types are required to implement serde::Deserialize
, Debug
and
Default
.
use pingora_core::server::configuration::ServerConf;
use module_utils::{merge_conf, FromYaml};
use static_files_module::StaticFilesConf;
use serde::Deserialize;
#[derive(Debug, Default, Deserialize)]
struct MyAppConf {
/// IP address and port for the server to listen on
listen: String,
}
#[merge_conf]
struct Conf {
app: MyAppConf,
server: ServerConf,
static_files: StaticFilesConf,
}
let conf = Conf::load_from_yaml("test.yaml").ok().unwrap_or_else(Conf::default);
println!("Application settings: {:?}", conf.app);
println!("Pingora server settings: {:?}", conf.server);
println!("Static files settings: {:?}", conf.static_files);