From ff79c1fcfbb7b8db66b183497dd36b56f2c917c8 Mon Sep 17 00:00:00 2001 From: neon_arch Date: Tue, 11 Jul 2023 19:38:59 +0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20code=20to=20parse=20and=20h?= =?UTF-8?q?andle=20the=20new=20config=20option?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config_parser/parser.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/config_parser/parser.rs b/src/config_parser/parser.rs index 4c5c1e6..c3e503d 100644 --- a/src/config_parser/parser.rs +++ b/src/config_parser/parser.rs @@ -3,7 +3,7 @@ use super::parser_models::Style; use rlua::Lua; -use std::{format, fs, path::Path}; +use std::{collections::HashMap, format, fs, path::Path}; // ------- Constants -------- static COMMON_DIRECTORY_NAME: &str = "websurfx"; @@ -27,6 +27,7 @@ pub struct Config { pub aggregator: AggreatorConfig, pub logging: bool, pub debug: bool, + pub upstream_search_engines: Vec, } /// Configuration options for the aggregator. @@ -75,6 +76,11 @@ impl Config { aggregator: aggregator_config, logging: globals.get::<_, bool>("logging")?, debug: globals.get::<_, bool>("debug")?, + upstream_search_engines: globals + .get::<_, HashMap>("upstream_search_engines")? + .into_iter() + .filter_map(|(key, value)| value.then(|| key)) + .collect(), }) }) }