-
-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
how can i override config by .env and .env.dev .env.prod #65
Comments
@Silentdoer that's how I implemented it in my project following the "Zero to production in Rust" book (it is recommended to use YAMLs there but I decided to do it my way): https://github.com/serge-klochkov/zero2prod/blob/main/src/config.rs#L24-L45 |
@arniu you can do it manually, just load it first use serde::Deserialize;
#[derive(Deserialize, Debug)]
pub struct Config {
pub pg_db_url: String,
pub mysql_db_url: String,
}
pub fn config() -> Result<Config, envy::Error> {
dotenvy::dotenv().ok(); // !
envy::from_env::<Config>()
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
💡 Feature description
💻 Basic example
The text was updated successfully, but these errors were encountered: