summaryrefslogtreecommitdiff
path: root/src/config.rs
diff options
context:
space:
mode:
authorSanto Cariotti <santo@dcariotti.me>2024-08-20 17:50:24 +0200
committerSanto Cariotti <santo@dcariotti.me>2024-08-20 17:50:24 +0200
commit3c8b004d6ecb6764cd5bc935aaeaf884040320ab (patch)
treeaf968fb3c598dde61edbe7c87de665f14a0be028 /src/config.rs
Init
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");
+}