Hi, I'm trying to use the config crate in my project and can't seem to make nested env variables work Could you please upload a .env,example to see how you are working with the separators.
#[derive(Debug, Deserialize)]
pub struct AppConfig {
pub database: DatabaseConfig,
pub upload: UploadConfig,
pub salt: String,
}
#[derive(Debug, Deserialize)]
pub struct UploadConfig {
pub max_file_size: usize,
pub allowed_types: Vec<String>,
pub storage_prefix: String,
}
#[derive(Debug, Deserialize)]
pub struct DatabaseConfig {
pub url: String,
}
impl AppConfig {
pub fn from_env() -> Result<AppConfig, ConfigError> {
let config = Config::builder()
.add_source(Environment::default().separator("_").try_parsing(true))
.add_source(
Environment::with_prefix("UPLOAD")
.prefix_separator("_")
.separator("_")
.try_parsing(true)
.with_list_parse_key("ALLOWED_TYPES"),
)
.build()?;
// println!("Config values: {:#?}", config);
config.try_deserialize()
}
}
with my .env having
DATABASE_URL=
SALT=
UPLOAD_MAX_FILE_SIZE=
UPLOAD_ALLOWED_TYPES=
UPLOAD_STORAGE_PREFIX=
Hi, I'm trying to use the
configcrate in my project and can't seem to make nested env variables work Could you please upload a.env,exampleto see how you are working with the separators.with my .env having