summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSanto Cariotti <santo@dcariotti.me>2021-03-09 20:53:47 +0100
committerSanto Cariotti <santo@dcariotti.me>2021-03-09 20:53:47 +0100
commit032f031f014c30049340bbb9f7d708bbf558ac3f (patch)
tree5c12b78c54bd3ff640a2b461d541cd651be70125 /src
parent715e87d4443688e63bdbb218d52d5b6c65f389a9 (diff)
feat: add config module
Diffstat (limited to 'src')
-rw-r--r--src/config.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/config.rs b/src/config.rs
new file mode 100644
index 0000000..f10fd08
--- /dev/null
+++ b/src/config.rs
@@ -0,0 +1,15 @@
+pub use config::ConfigError;
+use serde::Deserialize;
+
+#[derive(Deserialize)]
+pub struct Config {
+ pub pg: deadpool_postgres::Config,
+}
+
+impl Config {
+ pub fn from_env() -> Result<Self, ConfigError> {
+ let mut cfg = config::Config::new();
+ cfg.merge(config::Environment::new())?;
+ cfg.try_into()
+ }
+}