Skip to content

Commit

Permalink
set default host to be 0.0.0.0 and allow HOST and PORT to be set via …
Browse files Browse the repository at this point in the history
…environment variable
  • Loading branch information
prabirshrestha committed Sep 12, 2022
1 parent ee4da21 commit 9921007
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ pub async fn run() -> Result<()> {
hyper::server::Server::from_tcp(listener)?,
)
} else {
let addr: SocketAddr = "127.0.0.1:8080".parse()?;
let addr: SocketAddr = format!(
"{}:{}",
std::env::var("HOST").unwrap_or("0.0.0.0".into()),
std::env::var("PORT").unwrap_or("8080".into())
)
.parse()?;
(addr, hyper::server::Server::bind(&addr))
};

Expand Down

0 comments on commit 9921007

Please sign in to comment.