test: update tsts

This commit is contained in:
Sandro Eiler 2024-01-01 21:02:31 +01:00
parent 8257255dc2
commit 486271a523
3 changed files with 63 additions and 43 deletions

View file

@ -1,10 +1,21 @@
#[derive(serde::Deserialize)]
/// The application's settings
///
/// * `database`: database settings
/// * `application_port`: the port the app is running on
pub struct Settings {
pub database: DatabaseSettings,
pub application_port: u16,
}
#[derive(serde::Deserialize)]
/// The database settings
///
/// * `username`: the DB username
/// * `password`: the DB pasword
/// * `port`: the DB port
/// * `host`: the DB host address
/// * `database_name`: the DB name
pub struct DatabaseSettings {
pub username: String,
pub password: String,
@ -13,17 +24,14 @@ pub struct DatabaseSettings {
pub database_name: String,
}
/// Provides the application settings
pub fn get_configuration() -> Result<Settings, config::ConfigError> {
// Initialise our configuration reader
let settings = config::Config::builder()
// Add configuration values from a file named `configuration.yaml`.
.add_source(config::File::new(
"configuration.yaml",
config::FileFormat::Yaml,
))
.build()?;
// Try to convert the configuration values it read into
// our Settings type
settings.try_deserialize::<Settings>()
}

View file

@ -1,4 +1,4 @@
use axum::routing::get;
use axum::routing::post;
use axum::Router;
use serde::Deserialize;
@ -8,5 +8,5 @@ struct FormData {
name: String,
}
pub fn routes_subscriptions() -> Router {
Router::new().route("/subscriptions", get(|| async {}))
Router::new().route("/subscriptions", post(|| async {}))
}