Created
February 7, 2022 20:39
-
-
Save UltiRequiem/9a352f54f6df8084d4720792cb4f54a3 to your computer and use it in GitHub Desktop.
get env vars rust
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::env; | |
const DEFAULT_PORT: u16 = 3000; | |
const DEFAULT_SERVER_MODE: &str = "DEV"; | |
fn main() { | |
let server_port = env::var("SERVER_PORT").unwrap_or(DEFAULT_PORT.to_string()); | |
let server_mode = env::var("SERVER_MODE").unwrap_or(DEFAULT_SERVER_MODE.to_string()); | |
println!( | |
"Starting server in {} mode on port {}.", | |
server_mode, server_port | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment