mirror of
https://github.com/lldap/lldap.git
synced 2024-11-25 00:50:55 +00:00
Add complex configuration
This commit is contained in:
parent
845073c29d
commit
acc80d21e5
3 changed files with 34 additions and 13 deletions
13
Cargo.toml
13
Cargo.toml
|
@ -1,21 +1,16 @@
|
|||
[package]
|
||||
name = "lldap"
|
||||
authors = ["Valentin Tolmer <valentin@tolmer.fr>", "Steve Barrau <steve.barrau@gmail.com>", "Thomas Wickham <mackwic@gmail.com>"]
|
||||
edition = "2018"
|
||||
name = "lldap"
|
||||
version = "0.1.0"
|
||||
authors = [
|
||||
"Valentin Tolmer <valentin@tolmer.fr>",
|
||||
"Steve Barrau <steve.barrau@gmail.com>",
|
||||
"Thomas Wickham <mackwic@gmail.com>"
|
||||
]
|
||||
|
||||
[dependencies]
|
||||
clap = "3.0.0-beta.2"
|
||||
actix-web = "3"
|
||||
anyhow = "*"
|
||||
thiserror="*"
|
||||
clap = "3.0.0-beta.2"
|
||||
http = "*"
|
||||
passablewords = "*"
|
||||
serde = "*"
|
||||
thiserror = "*"
|
||||
tracing = "*"
|
||||
tracing-actix-web = "*"
|
||||
tracing-log = "*"
|
||||
|
|
2
lldap_config.toml
Normal file
2
lldap_config.toml
Normal file
|
@ -0,0 +1,2 @@
|
|||
# LLDAP configuration
|
||||
some_text = "ok boomer"
|
|
@ -1,6 +1,30 @@
|
|||
#[derive(Debug, Default)]
|
||||
pub struct Configuration;
|
||||
use anyhow::Result;
|
||||
use figment::{
|
||||
providers::{Env, Format, Serialized, Toml},
|
||||
Figment,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
pub fn init() -> Configuration {
|
||||
Configuration::default()
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
pub struct Configuration {
|
||||
secret_pepper: String,
|
||||
some_text: String,
|
||||
}
|
||||
|
||||
impl Default for Configuration {
|
||||
fn default() -> Self {
|
||||
Configuration {
|
||||
secret_pepper: String::from("secretsecretpepper"),
|
||||
some_text: String::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn init() -> Result<Configuration> {
|
||||
let config: Configuration = Figment::from(Serialized::defaults(Configuration::default()))
|
||||
.merge(Toml::file("lldap_config.toml"))
|
||||
.merge(Env::prefixed("LLDAP_"))
|
||||
.extract()?;
|
||||
|
||||
Ok(config)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue