diff --git a/src/main.rs b/src/main.rs index ace9968..817f8ac 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,6 +13,7 @@ use tracing::{error, info, metadata::LevelFilter}; use tracing_subscriber::{ filter::filter_fn, prelude::__tracing_subscriber_SubscriberExt, util::SubscriberInitExt, Layer, }; +use std::env; use types::extract::RequestIp; use crate::public::docs; @@ -73,7 +74,13 @@ async fn main() { .layer(CookieManagerLayer::new()) .layer(DefaultBodyLimit::max(512_000)); - let Ok(addr) = "[::]:8080".parse::() else { + let port: u16 = env::var("PORT") + .unwrap_or_else(|_| String::new()) + .parse::() + .unwrap_or(8080); + + let Ok(addr) = format!("[::]:{port}") + .parse::() else { error!("Failed to parse port binding"); exit(1) };