apub_inbox: Create basic structure

This commit is contained in:
Steffo 2024-12-13 04:42:38 +01:00
parent 8ef530658f
commit 5a746dd7b2
Signed by: steffo
GPG key ID: 5ADA3868646C3FC0
3 changed files with 38 additions and 2 deletions

View file

@ -0,0 +1,3 @@
micronfig::config!(
ACRATE_APUB_INBOX_BIND_ADDRESS: String,
);

View file

@ -1,3 +1,36 @@
fn main() { use std::sync::Arc;
println!("Hello, world!"); use anyhow::Context;
use axum::Extension;
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 Minijinja environment...");
let mut mj = minijinja::Environment::<'static>::new();
log::trace!("Creating Axum router...");
let app = axum::Router::new()
.layer(Extension(Arc::new(mj)));
log::trace!("Axum router created successfully!");
log::trace!("Creating Tokio listener...");
let bind_address = config::ACRATE_APUB_INBOX_BIND_ADDRESS();
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::info!("Starting apub_inbox web 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");
} }

View file