Allow port to be changed using MTT_PORT environment variable.

This commit is contained in:
2022-06-11 18:10:23 -04:00
parent d92761ed70
commit e40e190e1e
8 changed files with 597 additions and 30 deletions

View File

@ -1,9 +1,26 @@
use config::Config;
use tide::{http::StatusCode, Request, Response};
#[async_std::main]
async fn main() -> tide::Result<()> {
let settings = Config::builder()
.set_default("address", "127.0.0.1")?
.set_default("port", "9090")?
.add_source(
config::Environment::with_prefix("MTT")
.try_parsing(true)
.separator("_")
.list_separator(" "),
)
.build()
.unwrap();
let app = app_setup().await;
app.listen("127.0.0.1:9090").await?;
app.listen(format!(
"{}:{}",
settings.get_string("address").unwrap(),
settings.get_string("port").unwrap()
))
.await?;
Ok(())
}