SERVER_PROTOCOL is now an official env variable for the json-api to read

This commit is contained in:
shockrah 2021-03-07 23:55:38 -08:00
parent f14390f4bb
commit 7125fc954d
2 changed files with 4 additions and 1 deletions

View File

@ -12,3 +12,4 @@ SERVER_NAME="Freechat Dev Server"
SERVER_DESCRIPTION="Server for sick development things" SERVER_DESCRIPTION="Server for sick development things"
SERVER_HOSTNAME=localhost SERVER_HOSTNAME=localhost
SERVER_PORT=4536 SERVER_PORT=4536
SERVER_PROTOCOL=http

View File

@ -10,7 +10,8 @@ pub struct Config {
pub name: String, pub name: String,
pub description: String, pub description: String,
pub hostname: String, pub hostname: String,
pub port: u16 pub port: u16,
pub protocol: String,
} }
pub fn get_config() -> Config { pub fn get_config() -> Config {
@ -19,6 +20,7 @@ pub fn get_config() -> Config {
description: var("SERVER_DESCRIPTION").unwrap_or("No description".into()), description: var("SERVER_DESCRIPTION").unwrap_or("No description".into()),
hostname: var("SERVER_HOSTNAME").expect("Couldn't get url from environment"), hostname: var("SERVER_HOSTNAME").expect("Couldn't get url from environment"),
port: var("SERVER_PORT").expect("Couldn't get port from environment").parse::<u16>().unwrap(), port: var("SERVER_PORT").expect("Couldn't get port from environment").parse::<u16>().unwrap(),
protocol: var("SERVER_PROTOCOL").expect("Couldn't get protocol from environment")
} }
} }