Skip to content

Commit

Permalink
Add dotenv support
Browse files Browse the repository at this point in the history
  • Loading branch information
jkcdarunday committed Aug 3, 2023
1 parent fedfcce commit ff02e2c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ serde_json = "1.0.104"
actix-rt = "2.8.0"
config = "0.13.3"
lazy_static = "1.4.0"
dotenv = "0.15.0"

[dependencies.diesel]
features = ["postgres", "r2d2"]
Expand Down
3 changes: 3 additions & 0 deletions src/app/config.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use config::Config;
use dotenv::dotenv;

lazy_static! {
pub static ref CONFIG: Config = Config::builder()
Expand All @@ -9,5 +10,7 @@ lazy_static! {
}

pub fn get<'a, T: serde::Deserialize<'a>>(key: &str) -> T {
dotenv().ok();

CONFIG.get::<T>(key).unwrap()
}
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ extern crate serde;
#[macro_use]
extern crate lazy_static;
extern crate config;
extern crate dotenv;

use actix_web::web::Data;
use actix_web::{middleware, App, HttpServer};
Expand Down

0 comments on commit ff02e2c

Please sign in to comment.