[web] Respect config settings where possible

This commit is contained in:
Emi Simpson 2021-10-30 10:56:08 -04:00
parent 6e1afdb4b6
commit 37c0390678
Signed by: Emi
GPG Key ID: A12F2C2FFDC3D847
1 changed files with 9 additions and 6 deletions

View File

@ -171,17 +171,20 @@ async fn main() -> std::io::Result<()> {
}
};
log::info!("Starting with configuration {:?}", config);
start_server().await
start_server(config).await
}
}
}
async fn start_server() -> std::io::Result<()> {
println!("Starting pronouns-today-web on 127.0.0.1:8080");
HttpServer::new(|| {
async fn start_server(config: configuration::Conf) -> std::io::Result<()> {
// Where we binding bois
let bind = format!("0.0.0.0:{}", config.port);
println!("Starting pronouns-today-web on {}", &bind);
HttpServer::new(move|| {
let logger = Logger::default();
let app = App::new()
.data(InstanceSettings::default())
.data(config.instance_settings.clone())
.wrap(logger)
.wrap(middleware::NormalizePath::new(TrailingSlash::Trim))
.service(create_link);
@ -201,7 +204,7 @@ async fn start_server() -> std::io::Result<()> {
.service(resource("/{name}/{prefs}").to(handle_basic_request))
.default_service(web::to(not_found))
})
.bind("0.0.0.0:8080")?
.bind(&bind)?
.run()
.await
}