ilmen_http/http/configuration/
configuration.rs

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
use crate::http::security::service::SecurityProtocol;


#[derive(Clone)]
pub struct Config {
    port: Port,
    ip: Ip,
    security: SecurityProtocol
}


type Port = i32;
type Ip = String;

impl Default for Config {
    fn default() -> Self {
        Self { 
            port: 7878, 
            ip: "127.0.0.1".to_string(),
            security: SecurityProtocol::None
        }
    }
}

impl Config {
    pub fn adresse(&self) -> String {
        format!("{}:{}", self.ip, self.port)
    }

    pub fn security(&self) -> SecurityProtocol {
        self.security.clone()
    }

    pub fn new(port: Port, security: SecurityProtocol) -> Config {
        Config {
            port,
            security,
            ..Default::default()
        }
    }
}