21 lines
659 B
Rust
21 lines
659 B
Rust
use std::env;
|
|
|
|
#[derive(Clone, Debug)]
|
|
pub struct Config {
|
|
pub database_url: String,
|
|
pub bind: String,
|
|
pub timezone: String,
|
|
pub exports_dir: String,
|
|
}
|
|
|
|
impl Config {
|
|
pub fn from_env() -> Self {
|
|
Self {
|
|
database_url: env::var("DATABASE_URL")
|
|
.unwrap_or_else(|_| "sqlite:subnet-allocator.db".to_string()),
|
|
bind: env::var("APP_BIND").unwrap_or_else(|_| "0.0.0.0:8080".to_string()),
|
|
timezone: env::var("APP_TIMEZONE").unwrap_or_else(|_| "Europe/Prague".to_string()),
|
|
exports_dir: env::var("APP_EXPORTS_DIR").unwrap_or_else(|_| "./exports".to_string()),
|
|
}
|
|
}
|
|
}
|