Switched to yaml-based config

This commit is contained in:
Jef Roosens 2021-08-30 14:27:54 +02:00
parent 02011e04ce
commit 3cf7661faf
Signed by: Jef Roosens
GPG key ID: B580B976584B5F30
5 changed files with 62 additions and 14 deletions

View file

@ -10,6 +10,7 @@ extern crate diesel;
use rocket::{fairing::AdHoc, Build, Rocket};
use rocket_sync_db_pools::database;
use figment::{Figment, providers::Env, providers::Yaml, providers::Format};
mod admin;
pub mod auth;
@ -63,7 +64,11 @@ async fn create_admin_user(rocket: Rocket<Build>) -> Result<Rocket<Build>, Rocke
#[launch]
fn rocket() -> _
{
rocket::build()
let figment = Figment::from(rocket::config::Config::default())
.merge(Yaml::file("Rb.yaml").nested())
.merge(Env::prefixed("RB_").global());
rocket::custom(figment)
.attach(RbDbConn::fairing())
.attach(AdHoc::try_on_ignite(
"Run database migrations",