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
//! A configuration for a server.

use std::net::SocketAddr;
use typed_builder::TypedBuilder;

/// The configuration for a server.
#[derive(Clone, Debug, TypedBuilder)]
pub struct Config {
    /// The listen address.
    #[builder(default = "127.0.0.1:3000".parse().unwrap())]
    pub sock: SocketAddr,

    /// The log level when set at server startup.
    #[builder(default = None)]
    pub log: Option<String>,

    /// The path to provide home page. The home page should presents the installation button.
    #[builder(default = "/".into())]
    pub home_path: String,

    /// The path to receive a slash command request.
    #[builder(default = "/slash-command".into())]
    pub slash_command_path: String,

    /// The path to receive a OAuth request.
    #[builder(default = "/oauth/v2/redirect".into())]
    pub oauth_path: String,

    /// The configuration to serve static files.
    #[builder(default = StaticPathConfig::builder().build())]
    pub static_path: StaticPathConfig,
}

/// The configuration to serve static files.
#[derive(Clone, Debug, TypedBuilder)]
pub struct StaticPathConfig {
    /// The HTTP path to serve static files.
    #[builder(default = "/remote".to_string())]
    pub http: String,

    /// The local directory path to serve static files.
    #[builder(default = "./assets/remote".to_string())]
    pub local: String,
}