summaryrefslogtreecommitdiff
path: root/webhook/src/utils.rs
diff options
context:
space:
mode:
authorMatthieu <matthieu@developershouse.xyz>2021-09-09 22:16:39 +0400
committerMatthieu <matthieu@developershouse.xyz>2021-09-09 22:16:39 +0400
commit11912b050a97c258a8a38552d855f183c339beee (patch)
treed80f960beb4e0455cd8d0d8addb7b3308dda6933 /webhook/src/utils.rs
parente28d134370196d3e4d3ff9016a36cce011031e58 (diff)
gateway improvements, common packages and examples
Diffstat (limited to 'webhook/src/utils.rs')
-rw-r--r--webhook/src/utils.rs48
1 files changed, 0 insertions, 48 deletions
diff --git a/webhook/src/utils.rs b/webhook/src/utils.rs
deleted file mode 100644
index 442b5ba..0000000
--- a/webhook/src/utils.rs
+++ /dev/null
@@ -1,48 +0,0 @@
-use std::env;
-
-use config::{Config, ConfigError, Environment, File};
-use log::info;
-use serde::Deserialize;
-
-/// Executes the required configuration steps for the program,
-/// excluding build information, Sentry and logging.
-pub fn setup_program(_name: &str) {
- pretty_env_logger::init();
-}
-
-#[derive(Debug, Deserialize, Clone)]
-pub struct Server {
- pub port: u16,
- pub address: String,
-}
-
-#[derive(Debug, Deserialize, Clone)]
-pub struct Discord {
- pub public_key: String,
- pub client_id: u32,
-}
-
-#[derive(Debug, Deserialize, Clone)]
-pub struct Settings {
- pub server: Server,
- pub discord: Discord,
-}
-
-impl Settings {
- pub fn new() -> Result<Self, ConfigError> {
- let mut default = Config::default();
- default.merge(File::with_name("config/default"))?;
- let mode = env::var("ENV").unwrap_or_else(|_| "development".into());
- info!("Configuration Environment: {}", mode);
-
- default.merge(File::with_name(&format!("config/{}", mode)).required(false))?;
- default.merge(File::with_name("config/local").required(false))?;
- default.merge(Environment::with_prefix("NOVA_GATEWAY"))?;
-
- println!("Debug mode: {:?}", default.get_bool("debug"));
-
- let config: Self = default.try_into().unwrap();
-
- Ok(config)
- }
-}