use std::env;
#[derive(Debug)]
pub struct ServerConfig {
pub host: String,
pub port: u16,
pub api_version: String,
}
impl ServerConfig {
pub fn from_env() -> Self {
let host = env::var("HOST").unwrap_or_else(|_| "127.0.0.1".to_string());
let port = env::var("PORT")
.unwrap_or_else(|_| "8080".to_string())
.parse::<u16>()
.expect("PORT must be a valid u16 tyle");
let api_version = env::var("API_VERSION").unwrap_or_else(|_| "v001".to_string());
Self {
host,
port,
api_version,
}
}
}