mirror of
https://github.com/neon-mmd/websurfx.git
synced 2024-11-22 05:58:21 -05:00
✨ feat: add code to parse the new config option (#201)
This commit is contained in:
parent
d6463f0872
commit
37e650eb8a
@ -35,6 +35,7 @@ pub struct Config {
|
|||||||
pub upstream_search_engines: Vec<crate::engines::engine_models::EngineHandler>,
|
pub upstream_search_engines: Vec<crate::engines::engine_models::EngineHandler>,
|
||||||
pub request_timeout: u8,
|
pub request_timeout: u8,
|
||||||
pub threads: u8,
|
pub threads: u8,
|
||||||
|
pub safe_search: u8,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Configuration options for the aggregator.
|
/// Configuration options for the aggregator.
|
||||||
@ -88,6 +89,16 @@ impl Config {
|
|||||||
parsed_threads
|
parsed_threads
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let parsed_safe_search:u8 = globals.get::<_,u8>("safe_search")?;
|
||||||
|
let safe_search: u8 = match parsed_safe_search {
|
||||||
|
0..=4 => parsed_safe_search,
|
||||||
|
_ => {
|
||||||
|
log::error!("Config Error: The value of `safe_search` option should be a non zero positive integer from 0 to 4.");
|
||||||
|
log::error!("Falling back to using the value `1` for the option");
|
||||||
|
1
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
Ok(Config {
|
Ok(Config {
|
||||||
port: globals.get::<_, u16>("port")?,
|
port: globals.get::<_, u16>("port")?,
|
||||||
binding_ip: globals.get::<_, String>("binding_ip")?,
|
binding_ip: globals.get::<_, String>("binding_ip")?,
|
||||||
@ -109,6 +120,7 @@ impl Config {
|
|||||||
.collect(),
|
.collect(),
|
||||||
request_timeout: globals.get::<_, u8>("request_timeout")?,
|
request_timeout: globals.get::<_, u8>("request_timeout")?,
|
||||||
threads,
|
threads,
|
||||||
|
safe_search
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user