[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

View file

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