Skip to main content

modo/server/
config.rs

1use serde::Deserialize;
2
3/// HTTP server configuration.
4///
5/// Deserialized from the `server` section of the application YAML config file.
6/// All fields have sane defaults so the section may be omitted entirely.
7///
8/// # YAML example
9///
10/// ```yaml
11/// server:
12///   host: 0.0.0.0
13///   port: ${PORT:8080}
14///   shutdown_timeout_secs: 30
15/// ```
16#[non_exhaustive]
17#[derive(Debug, Clone, Deserialize)]
18#[serde(default)]
19pub struct Config {
20    /// Network interface to bind. Defaults to `"localhost"`.
21    pub host: String,
22    /// TCP port to listen on. Defaults to `8080`.
23    pub port: u16,
24    /// Maximum seconds to wait for in-flight requests to complete during
25    /// graceful shutdown. Defaults to `30`.
26    pub shutdown_timeout_secs: u64,
27}
28
29impl Default for Config {
30    fn default() -> Self {
31        Self {
32            host: "localhost".to_string(),
33            port: 8080,
34            shutdown_timeout_secs: 30,
35        }
36    }
37}