1
Fork 0

webfinger: Parse query string with serde and axum_extra

This commit is contained in:
Steffo 2024-11-14 04:02:40 +01:00
parent 646696a49e
commit 8145ce57cc
Signed by: steffo
GPG key ID: 5ADA3868646C3FC0
4 changed files with 19 additions and 8 deletions

View file

@ -9,6 +9,7 @@
<sourceFolder url="file://$MODULE_DIR$/acrate-inbox/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/acrate-nodeinfo/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/acrate-nodeinfo/tests" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/acrate-webfinger/src" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />

View file

@ -6,7 +6,9 @@ edition = "2021"
[dependencies]
anyhow = "1.0.93"
axum = "0.7.7"
axum-extra = { version = "0.9.4", features = ["query"] }
log = "0.4.22"
micronfig = "0.3.0"
pretty_env_logger = "0.5.0"
serde = { version = "1.0.215", features = ["derive"] }
tokio = { version = "1.41.1", features = ["macros", "net", "rt-multi-thread"] }

View file

@ -11,7 +11,7 @@ async fn main() -> anyhow::Result<std::convert::Infallible> {
log::trace!("Creating Axum router...");
let app = axum::Router::new()
.route("/inbox", axum::routing::post(route::inbox_handler));
.route("/.well-known/webfinger", axum::routing::get(route::webfinger_handler));
log::trace!("Axum router created successfully!");
log::trace!("Creating Tokio listener...");

View file

@ -1,8 +1,16 @@
#[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");
use axum_extra::extract::Query;
use serde::Deserialize;
#[derive(Debug, Clone, Deserialize)]
pub struct WebfingerQuery {
pub resource: String,
#[serde(default)]
pub rel: Vec<String>,
}
pub async fn webfinger_handler(
Query(WebfingerQuery {resource, rel}): Query<WebfingerQuery>
) {
todo!()
}