blob: dc132b888b9a9db351b92d229130085ab617dd1a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#[derive(Debug, Default, Clone)]
pub struct Config {
pub database_url: String,
pub jwt_secret: String,
pub jwt_expires_in: String,
pub jwt_maxage: i32,
}
impl Config {
pub fn init() -> Config {
let mut config = Config::default();
if let Ok(database_url) = std::env::var("DATABASE_URL") {
config.database_url = database_url;
};
if let Ok(jwt_secret) = std::env::var("JWT_SECRET") {
config.jwt_secret = jwt_secret;
};
if let Ok(jwt_expires_in) = std::env::var("JWT_EXPIRED_IN") {
config.jwt_expires_in = jwt_expires_in;
};
if let Ok(jwt_maxage) = std::env::var("JWT_MAXAGE") {
config.jwt_maxage = jwt_maxage.parse::<i32>().unwrap();
};
config
}
}
|