mirror of
https://github.com/OMGeeky/confique.git
synced 2025-12-29 15:56:00 +01:00
Do major refactor of format code
This gets rid of a lot of duplicated logic that was previously copy&pasted. This commit alos: - Makes it easier to implement new formats - Gets rid of a few bugs - Makes the system more flexible (more options) - Adds a lot of additional tests
This commit is contained in:
44
src/test_utils/example2.rs
Normal file
44
src/test_utils/example2.rs
Normal file
@@ -0,0 +1,44 @@
|
||||
use std::path::PathBuf;
|
||||
|
||||
use crate::Config;
|
||||
use crate as confique;
|
||||
|
||||
#[derive(Debug, Config)]
|
||||
/// A sample configuration for our app.
|
||||
pub struct Conf {
|
||||
#[config(nested)]
|
||||
pub http: Http,
|
||||
}
|
||||
|
||||
/// Configuring the HTTP server of our app.
|
||||
#[derive(Debug, Config)]
|
||||
pub struct Http {
|
||||
#[config(nested)]
|
||||
pub headers: Headers,
|
||||
|
||||
#[config(nested)]
|
||||
pub log: LogConfig,
|
||||
}
|
||||
|
||||
#[derive(Debug, Config)]
|
||||
pub struct Headers {
|
||||
/// The header in which the reverse proxy specifies the username.
|
||||
#[config(default = "x-username")]
|
||||
pub username: String,
|
||||
|
||||
/// The header in which the reverse proxy specifies the display name.
|
||||
#[config(default = "x-display-name")]
|
||||
pub display_name: String,
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug, Config)]
|
||||
pub struct LogConfig {
|
||||
/// If set to `true`, the app will log to stdout.
|
||||
#[config(default = true)]
|
||||
pub stdout: bool,
|
||||
|
||||
/// If this is set, the app will write logs to the given file. Of course,
|
||||
/// the app has to have write access to that file.
|
||||
pub file: Option<PathBuf>,
|
||||
}
|
||||
Reference in New Issue
Block a user