Skip to content

Commit

Permalink
Add dotenv to allow router to read environment variables from .env file
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewmcgivery committed Oct 3, 2024
1 parent b90786d commit 54fd75c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ dependencies = [
"dhat",
"diff",
"displaydoc",
"dotenv",
"ecdsa",
"flate2",
"fred",
Expand Down Expand Up @@ -2249,6 +2250,12 @@ dependencies = [
"syn 2.0.76",
]

[[package]]
name = "dotenv"
version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f"

[[package]]
name = "downcast"
version = "0.11.0"
Expand Down
1 change: 1 addition & 0 deletions apollo-router/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ bytesize = { version = "1.3.0", features = ["serde"] }
ahash = "0.8.11"
itoa = "1.0.9"
ryu = "1.0.15"
dotenv = "0.15.0"

[target.'cfg(macos)'.dependencies]
uname = "0.1.1"
Expand Down
3 changes: 3 additions & 0 deletions apollo-router/src/executable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use clap::Args;
use clap::CommandFactory;
use clap::Parser;
use clap::Subcommand;
use dotenv::dotenv;
#[cfg(any(feature = "dhat-heap", feature = "dhat-ad-hoc"))]
use once_cell::sync::OnceCell;
use regex::Captures;
Expand Down Expand Up @@ -398,6 +399,8 @@ impl Executable {
config: Option<ConfigurationSource>,
cli_args: Option<Opt>,
) -> Result<()> {
dotenv().ok();

let opt = cli_args.unwrap_or_else(Opt::parse);

if opt.version {
Expand Down

0 comments on commit 54fd75c

Please sign in to comment.