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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
use anyhow::Result;
use serde::Deserialize;
use std::{fs::read_to_string, path::PathBuf};
#[derive(Clone, Deserialize)]
pub struct Config {
pub server: ServerConfig,
pub log: LogConfig,
pub postgres: PostgresConfig,
}
impl Config {
pub fn from_file(filename: &str) -> Result<Self> {
Ok(toml::from_str(&read_to_string(filename)?)?)
}
}
#[derive(Clone, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub struct ServerConfig {
pub url: String,
pub cert: PathBuf,
pub key: PathBuf,
pub redirect_from: Vec<String>,
}
#[derive(Clone, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub struct LogConfig {
pub actix_web: String,
pub webapp: String,
}
#[derive(Clone, Deserialize)]
pub struct PostgresConfig {
pub host: String,
pub username: String,
pub password: String,
pub database: String,
}