Change RouilleConfig to ServerConfig
continuous-integration/drone/pr Build is failing
Details
continuous-integration/drone/pr Build is failing
Details
This commit is contained in:
parent
e041e1c7f9
commit
99fd3be4ad
|
@ -9,17 +9,17 @@
|
|||
use crate::error::PeachWebError;
|
||||
use peach_lib::config_manager::get_config_value;
|
||||
|
||||
pub struct RouilleConfig {
|
||||
pub struct ServerConfig {
|
||||
pub standalone_mode: bool,
|
||||
pub disable_auth: bool,
|
||||
pub addr: String,
|
||||
pub port: String,
|
||||
}
|
||||
|
||||
impl RouilleConfig {
|
||||
pub fn new() -> Result<RouilleConfig, PeachWebError> {
|
||||
impl ServerConfig {
|
||||
pub fn new() -> Result<ServerConfig, PeachWebError> {
|
||||
// define default config values
|
||||
let config = RouilleConfig {
|
||||
let config = ServerConfig {
|
||||
standalone_mode: get_config_value("STANDALONE_MODE")?.as_str() == "true",
|
||||
disable_auth: get_config_value("DISABLE_AUTH")?.as_str() == "true",
|
||||
addr: get_config_value("ADDR")?,
|
||||
|
|
|
@ -29,12 +29,12 @@ use lazy_static::lazy_static;
|
|||
use log::info;
|
||||
|
||||
// crate-local dependencies
|
||||
use config::RouilleConfig;
|
||||
use config::ServerConfig;
|
||||
use utils::theme::Theme;
|
||||
|
||||
// load the application configuration and create the theme switcher
|
||||
lazy_static! {
|
||||
static ref ROUILLE_CONFIG: RouilleConfig = RouilleConfig::new()
|
||||
static ref SERVER_CONFIG: ServerConfig = ServerConfig::new()
|
||||
.expect("Failed to load rouille configuration values on server startup");
|
||||
static ref THEME: RwLock<Theme> = RwLock::new(Theme::Light);
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ fn main() {
|
|||
|
||||
// set ip address / hostname and port for the webserver
|
||||
// defaults to "127.0.0.1:8000"
|
||||
let addr_and_port = format!("{}:{}", ROUILLE_CONFIG.addr, ROUILLE_CONFIG.port);
|
||||
let addr_and_port = format!("{}:{}", SERVER_CONFIG.addr, SERVER_CONFIG.port);
|
||||
|
||||
// store the session data for each session and a hashmap that associates
|
||||
// each session id with the data
|
||||
|
@ -68,7 +68,7 @@ fn main() {
|
|||
// with a name of "SID" and a duration of one hour (3600 seconds)
|
||||
rouille::session::session(request, "SID", 3600, |session| {
|
||||
// if the "DISABLE_AUTH" env var is true, authenticate the session
|
||||
let mut session_data = if ROUILLE_CONFIG.disable_auth {
|
||||
let mut session_data = if SERVER_CONFIG.disable_auth {
|
||||
Some(SessionData {
|
||||
_login: "success".to_string(),
|
||||
})
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use maud::{html, PreEscaped};
|
||||
|
||||
use crate::{templates, utils::theme, ROUILLE_CONFIG};
|
||||
use crate::{templates, utils::theme, SERVER_CONFIG};
|
||||
|
||||
// ROUTE: /settings
|
||||
|
||||
|
@ -12,7 +12,7 @@ pub fn build_template() -> PreEscaped<String> {
|
|||
(PreEscaped("<!-- BUTTONS -->"))
|
||||
div id="settingsButtons" {
|
||||
// render the network settings button if we're not in standalone mode
|
||||
@if !ROUILLE_CONFIG.standalone_mode {
|
||||
@if !SERVER_CONFIG.standalone_mode {
|
||||
a id="network" class="button button-primary center" href="/settings/network" title="Network Settings" { "Network" }
|
||||
}
|
||||
a id="scuttlebutt" class="button button-primary center" href="/settings/scuttlebutt" title="Scuttlebutt Settings" { "Scuttlebutt" }
|
||||
|
|
Loading…
Reference in New Issue