2024-11-14 02:50:59 +00:00
|
|
|
use anyhow::Context;
|
|
|
|
|
|
|
|
mod config;
|
|
|
|
mod route;
|
|
|
|
|
|
|
|
|
|
|
|
#[tokio::main]
|
|
|
|
async fn main() -> anyhow::Result<std::convert::Infallible> {
|
|
|
|
pretty_env_logger::init();
|
|
|
|
log::debug!("Logging initialized!");
|
|
|
|
|
|
|
|
log::trace!("Creating Axum router...");
|
|
|
|
let app = axum::Router::new()
|
2024-11-14 03:02:40 +00:00
|
|
|
.route("/.well-known/webfinger", axum::routing::get(route::webfinger_handler));
|
2024-11-14 02:50:59 +00:00
|
|
|
log::trace!("Axum router created successfully!");
|
|
|
|
|
|
|
|
log::trace!("Creating Tokio listener...");
|
2024-11-14 03:16:12 +00:00
|
|
|
let bind_address = config::ACRATE_WEBFINGER_BIND_ADDRESS();
|
2024-11-14 02:50:59 +00:00
|
|
|
let listener = tokio::net::TcpListener::bind(bind_address)
|
|
|
|
.await
|
|
|
|
.context("failed to bind listener to address")?;
|
|
|
|
log::trace!("Tokio listener bound to: {bind_address}");
|
|
|
|
|
|
|
|
log::debug!("Starting server...");
|
|
|
|
axum::serve(listener, app)
|
|
|
|
.await
|
|
|
|
.context("server exited with error")?;
|
|
|
|
|
|
|
|
log::error!("Server exited with no error, panicking.");
|
|
|
|
panic!("server exited with no error");
|
|
|
|
}
|