mirror of
https://github.com/nitnelave/lldap.git
synced 2023-04-12 14:25:13 +00:00
Add complex configuration
This commit is contained in:
parent
845073c29d
commit
acc80d21e5
13
Cargo.toml
13
Cargo.toml
@ -1,21 +1,16 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "lldap"
|
authors = ["Valentin Tolmer <valentin@tolmer.fr>", "Steve Barrau <steve.barrau@gmail.com>", "Thomas Wickham <mackwic@gmail.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
name = "lldap"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = [
|
|
||||||
"Valentin Tolmer <valentin@tolmer.fr>",
|
|
||||||
"Steve Barrau <steve.barrau@gmail.com>",
|
|
||||||
"Thomas Wickham <mackwic@gmail.com>"
|
|
||||||
]
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = "3.0.0-beta.2"
|
|
||||||
actix-web = "3"
|
actix-web = "3"
|
||||||
anyhow = "*"
|
anyhow = "*"
|
||||||
thiserror="*"
|
clap = "3.0.0-beta.2"
|
||||||
http = "*"
|
http = "*"
|
||||||
passablewords = "*"
|
passablewords = "*"
|
||||||
serde = "*"
|
serde = "*"
|
||||||
|
thiserror = "*"
|
||||||
tracing = "*"
|
tracing = "*"
|
||||||
tracing-actix-web = "*"
|
tracing-actix-web = "*"
|
||||||
tracing-log = "*"
|
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)]
|
use anyhow::Result;
|
||||||
pub struct Configuration;
|
use figment::{
|
||||||
|
providers::{Env, Format, Serialized, Toml},
|
||||||
|
Figment,
|
||||||
|
};
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
pub fn init() -> Configuration {
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
Configuration::default()
|
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 New Issue
Block a user