feat: add logic for journey->train identifier resolving, add recording of journeys, build api bearer auth
This commit is contained in:
50
src/config.rs
Normal file
50
src/config.rs
Normal file
@ -0,0 +1,50 @@
|
||||
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()
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user