@ -24,7 +24,9 @@ use serde::Deserialize;
|
||||
use url::Url;
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct Server {
|
||||
pub struct Settings {
|
||||
pub debug: bool,
|
||||
pub cache: Option<String>,
|
||||
pub port: u32,
|
||||
pub domain: String,
|
||||
pub ip: String,
|
||||
@ -32,28 +34,13 @@ pub struct Server {
|
||||
pub workers: Option<usize>,
|
||||
}
|
||||
|
||||
impl Server {
|
||||
#[cfg(not(tarpaulin_include))]
|
||||
pub fn get_ip(&self) -> String {
|
||||
format!("{}:{}", self.ip, self.port)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct Settings {
|
||||
pub debug: bool,
|
||||
pub cache: Option<String>,
|
||||
pub server: Server,
|
||||
pub source_code: String,
|
||||
}
|
||||
|
||||
#[cfg(not(tarpaulin_include))]
|
||||
impl Settings {
|
||||
pub fn new() -> Result<Self, ConfigError> {
|
||||
let mut s = Config::builder();
|
||||
|
||||
// setting default values
|
||||
const CURRENT_DIR: &str = "./config/default.toml";
|
||||
const CURRENT_DIR: &str = "./config.toml";
|
||||
const ETC: &str = "/etc/libmedium/config.toml";
|
||||
|
||||
if let Ok(path) = env::var("LIBMEDIUM") {
|
||||
@ -105,4 +92,9 @@ impl Settings {
|
||||
fn check_url(&self) {
|
||||
Url::parse(&self.source_code).expect("Please enter a URL for source_code in settings");
|
||||
}
|
||||
|
||||
#[cfg(not(tarpaulin_include))]
|
||||
pub fn get_ip(&self) -> String {
|
||||
format!("{}:{}", self.ip, self.port)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user