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
//! Provides default values for the configuration.

use crate::config::{
    BlacklistConfig, BlacklistMode, Config, ConfigSource, HostConfig, LoggingConfig, RouteConfig,
    RouteType,
};
use crate::server::logger::LogLevel;

impl Default for Config {
    fn default() -> Self {
        Self {
            source: ConfigSource::Default,
            address: "0.0.0.0".into(),
            port: 80,
            threads: 32,
            #[cfg(feature = "tls")]
            tls_config: None,
            default_websocket_proxy: None,
            hosts: Vec::new(),
            default_host: Default::default(),
            #[cfg(feature = "plugins")]
            plugins: Vec::new(),
            logging: Default::default(),
            cache: Default::default(),
            blacklist: Default::default(),
            connection_timeout: Default::default(),
        }
    }
}

impl Default for HostConfig {
    fn default() -> Self {
        Self {
            matches: "*".into(),
            routes: vec![Default::default()],
        }
    }
}

impl Default for RouteConfig {
    fn default() -> Self {
        Self {
            route_type: RouteType::Directory,
            matches: "/*".into(),
            path: Some('.'.into()),
            load_balancer: None,
            websocket_proxy: None,
        }
    }
}

impl Default for LoggingConfig {
    fn default() -> Self {
        Self {
            level: LogLevel::Info,
            console: true,
            file: None,
        }
    }
}

impl Default for BlacklistConfig {
    fn default() -> Self {
        Self {
            list: Default::default(),
            mode: BlacklistMode::Block,
        }
    }
}