From 4364de59a2d73798410b3779b7e973a54e45f288 Mon Sep 17 00:00:00 2001 From: necrashter Date: Sat, 23 Apr 2022 13:56:31 +0300 Subject: Read from config file at start-up --- src/main.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 57ee526..6edd67c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -35,12 +35,21 @@ pub use block::{Fingerprint, Id}; use db::Db; use lazy_static::lazy_static; use std::fs; +use crate::config::Config; #[tokio::main] async fn main() { log4rs::init_file("log.conf.yml", log4rs::config::Deserializers::default()).unwrap(); - let api = routes::application(Db::new()); + let config = match Config::read("config.yaml") { + Some(c) => c, + None => { + println!("Could not read config file, exiting."); + return; + }, + }; + + let api = routes::application(Db::new(config)); // Start the server let point = ([127, 0, 0, 1], 8080); -- cgit v1.2.3-70-g09d2