summaryrefslogtreecommitdiff
path: root/src/config.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/config.rs')
-rw-r--r--src/config.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/config.rs b/src/config.rs
new file mode 100644
index 0000000..cbea92e
--- /dev/null
+++ b/src/config.rs
@@ -0,0 +1,23 @@
+use config::ConfigError;
+use lazy_static::lazy_static;
+use serde::Deserialize;
+
+#[derive(Deserialize)]
+pub struct Configuration {
+ pub rust_log: String,
+ pub database_url: String,
+ pub jwt_secret: String,
+ pub allowed_host: String,
+}
+
+impl Configuration {
+ pub fn new() -> Result<Self, ConfigError> {
+ let builder = config::Config::builder().add_source(config::Environment::default());
+
+ builder.build()?.try_deserialize()
+ }
+}
+
+lazy_static! {
+ pub static ref CONFIG: Configuration = Configuration::new().expect("Config can be loaded");
+}