50 lines
1.0 KiB
Rust
50 lines
1.0 KiB
Rust
use std::net::IpAddr;
|
|
use serde::Deserialize;
|
|
use url::Url;
|
|
|
|
use config::{
|
|
Config,
|
|
ConfigError,
|
|
File,
|
|
};
|
|
|
|
#[derive(Debug, Clone, Deserialize)]
|
|
pub struct IceBingoConfig {
|
|
pub http: HttpServerConfig,
|
|
//pub oidc: OidcConfig,
|
|
pub database: DatabaseConfig,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Deserialize)]
|
|
pub struct HttpServerConfig {
|
|
pub bind_address: IpAddr,
|
|
pub port: u16,
|
|
}
|
|
#[derive(Debug, Clone, Deserialize)]
|
|
pub struct OidcConfig {
|
|
pub issuer: Url,
|
|
pub client_id: String,
|
|
pub client_secret: String,
|
|
pub callback: Url,
|
|
pub introspection_url: Url,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Deserialize)]
|
|
pub struct DatabaseConfig {
|
|
#[serde(rename = "type")]
|
|
pub db_type: String,
|
|
pub host: String,
|
|
pub user: String,
|
|
pub password: String,
|
|
pub database: String,
|
|
|
|
}
|
|
|
|
impl IceBingoConfig {
|
|
pub async fn load(filename: &str) -> Result<Self, ConfigError> {
|
|
Config::builder()
|
|
.add_source(File::with_name(filename))
|
|
.build()?
|
|
.try_deserialize()
|
|
}
|
|
} |