refactor: parameterize binding

This commit is contained in:
Max Hohlfeld 2024-07-23 14:25:09 +02:00
parent b220edf508
commit 5b85c0ad8e
2 changed files with 7 additions and 2 deletions

2
.env
View File

@ -5,6 +5,8 @@ DATABASE_URL=postgresql://max@localhost/brass
# 64 byte long
SECRET_KEY="changeInProdOrHandAb11111111111111111111111111111111111111111111"
HOSTNAME="localhost"
ADDRESS="127.0.0.1"
PORT="8080"
SMTP_SERVER="localhost"
SMTP_PORT="1025"

View File

@ -36,7 +36,10 @@ async fn main() -> anyhow::Result<()> {
handle_command(args.command, &pool).await?;
println!("Starting server on http://localhost:8080.");
let address = env::var("ADDRESS")?;
let port = env::var("PORT")?.parse()?;
println!("Starting server on http://{address}:{port}.");
HttpServer::new(move || {
let generated = generate();
@ -55,7 +58,7 @@ async fn main() -> anyhow::Result<()> {
.wrap(SessionMiddleware::new(store.clone(), secret_key.clone()))
.service(ResourceFiles::new("/static", generated))
})
.bind(("127.0.0.1", 8080))?
.bind((address, port))?
.run()
.await?;