Add settings and constants
This commit is contained in:
		
							parent
							
								
									e419923939
								
							
						
					
					
						commit
						ee68405874
					
				
					 6 changed files with 26 additions and 8 deletions
				
			
		| 
						 | 
				
			
			@ -1,4 +1,5 @@
 | 
			
		|||
use config::Config;
 | 
			
		||||
use emgauwa_lib::constants;
 | 
			
		||||
use serde_derive::Deserialize;
 | 
			
		||||
 | 
			
		||||
#[derive(Clone, Debug, Deserialize)]
 | 
			
		||||
| 
						 | 
				
			
			@ -23,7 +24,7 @@ impl Default for Settings {
 | 
			
		|||
	fn default() -> Self {
 | 
			
		||||
		Settings {
 | 
			
		||||
			database: String::from("sqlite://emgauwa-core.sqlite"),
 | 
			
		||||
			port: 5000,
 | 
			
		||||
			port: constants::DEFAULT_PORT,
 | 
			
		||||
			host: String::from("127.0.0.1"),
 | 
			
		||||
			logging: Logging::default(),
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -44,11 +45,11 @@ pub fn init() -> Settings {
 | 
			
		|||
		.add_source(config::File::with_name("emgauwa-core"))
 | 
			
		||||
		.add_source(
 | 
			
		||||
			config::Environment::with_prefix("EMGAUWA_CORE")
 | 
			
		||||
				.prefix_separator("_")
 | 
			
		||||
				.prefix_separator("__")
 | 
			
		||||
				.separator("__"),
 | 
			
		||||
		)
 | 
			
		||||
		.build()
 | 
			
		||||
		.unwrap()
 | 
			
		||||
		.try_deserialize::<Settings>()
 | 
			
		||||
		.unwrap_or_else(|_| panic!("Error reading settings."))
 | 
			
		||||
		.expect("Error reading settings.")
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue