Create webfinger
crate #5
5 changed files with 55 additions and 1 deletions
|
@ -1,3 +1,3 @@
|
||||||
[workspace]
|
[workspace]
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
members = ["acrate-core", "acrate-hostmeta", "acrate-inbox", "acrate-nodeinfo"]
|
members = ["acrate-core", "acrate-hostmeta", "acrate-inbox", "acrate-nodeinfo", "acrate-webfinger"]
|
||||||
|
|
12
acrate-webfinger/Cargo.toml
Normal file
12
acrate-webfinger/Cargo.toml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
[package]
|
||||||
|
name = "acrate-webfinger"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
anyhow = "1.0.93"
|
||||||
|
axum = "0.7.7"
|
||||||
|
log = "0.4.22"
|
||||||
|
micronfig = "0.3.0"
|
||||||
|
pretty_env_logger = "0.5.0"
|
||||||
|
tokio = { version = "1.41.1", features = ["macros", "net", "rt-multi-thread"] }
|
3
acrate-webfinger/src/config.rs
Normal file
3
acrate-webfinger/src/config.rs
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
micronfig::config!(
|
||||||
|
ACRATE_INBOX_BIND_ADDRESS: String,
|
||||||
|
);
|
31
acrate-webfinger/src/main.rs
Normal file
31
acrate-webfinger/src/main.rs
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
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()
|
||||||
|
.route("/inbox", axum::routing::post(route::inbox_handler));
|
||||||
|
log::trace!("Axum router created successfully!");
|
||||||
|
|
||||||
|
log::trace!("Creating Tokio listener...");
|
||||||
|
let bind_address = config::ACRATE_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::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");
|
||||||
|
}
|
8
acrate-webfinger/src/route.rs
Normal file
8
acrate-webfinger/src/route.rs
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#[allow(unreachable_code)]
|
||||||
|
pub async fn inbox_handler() {
|
||||||
|
todo!("pre-validation hook");
|
||||||
|
todo!("validate signature");
|
||||||
|
todo!("post-validation hook");
|
||||||
|
todo!("database storage");
|
||||||
|
todo!("post-storage hook");
|
||||||
|
}
|
Loading…
Reference in a new issue