From 025311e1009403877db9b74e82495aa8fb95d3fe Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Thu, 14 Nov 2024 04:16:12 +0100 Subject: [PATCH] `webfinger`: Properly handle requests --- acrate-webfinger/Cargo.toml | 2 +- acrate-webfinger/src/config.rs | 2 +- acrate-webfinger/src/main.rs | 2 +- acrate-webfinger/src/route.rs | 10 ++++++++-- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/acrate-webfinger/Cargo.toml b/acrate-webfinger/Cargo.toml index 5c74e51..34b5b6e 100644 --- a/acrate-webfinger/Cargo.toml +++ b/acrate-webfinger/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" [dependencies] anyhow = "1.0.93" -axum = "0.7.7" +axum = { version = "0.7.7", features = ["macros"] } axum-extra = { version = "0.9.4", features = ["query"] } log = "0.4.22" micronfig = "0.3.0" diff --git a/acrate-webfinger/src/config.rs b/acrate-webfinger/src/config.rs index 63babb0..535a5c4 100644 --- a/acrate-webfinger/src/config.rs +++ b/acrate-webfinger/src/config.rs @@ -1,3 +1,3 @@ micronfig::config!( - ACRATE_INBOX_BIND_ADDRESS: String, + ACRATE_WEBFINGER_BIND_ADDRESS: String, ); diff --git a/acrate-webfinger/src/main.rs b/acrate-webfinger/src/main.rs index cc8ad4d..de425ea 100644 --- a/acrate-webfinger/src/main.rs +++ b/acrate-webfinger/src/main.rs @@ -15,7 +15,7 @@ async fn main() -> anyhow::Result { log::trace!("Axum router created successfully!"); log::trace!("Creating Tokio listener..."); - let bind_address = config::ACRATE_INBOX_BIND_ADDRESS(); + let bind_address = config::ACRATE_WEBFINGER_BIND_ADDRESS(); let listener = tokio::net::TcpListener::bind(bind_address) .await .context("failed to bind listener to address")?; diff --git a/acrate-webfinger/src/route.rs b/acrate-webfinger/src/route.rs index 82a7986..47aac61 100644 --- a/acrate-webfinger/src/route.rs +++ b/acrate-webfinger/src/route.rs @@ -1,3 +1,4 @@ +use axum::http::StatusCode; use axum_extra::extract::Query; use serde::Deserialize; @@ -9,8 +10,13 @@ pub struct WebfingerQuery { pub rel: Vec, } +#[axum::debug_handler] pub async fn webfinger_handler( Query(WebfingerQuery {resource, rel}): Query -) { - todo!() +) -> StatusCode { + log::info!("Handling a WebFinger request!"); + log::debug!("Resource is: {resource:#?}"); + log::debug!("Rel is: {rel:#?}"); + + StatusCode::NO_CONTENT }