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-inbox/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/acrate-nodeinfo/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-nodeinfo/tests" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/acrate-webfinger/src" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/target" /> <excludeFolder url="file://$MODULE_DIR$/target" />
</content> </content>
<orderEntry type="inheritedJdk" /> <orderEntry type="inheritedJdk" />

View file

@ -6,7 +6,9 @@ edition = "2021"
[dependencies] [dependencies]
anyhow = "1.0.93" anyhow = "1.0.93"
axum = "0.7.7" axum = "0.7.7"
axum-extra = { version = "0.9.4", features = ["query"] }
log = "0.4.22" log = "0.4.22"
micronfig = "0.3.0" micronfig = "0.3.0"
pretty_env_logger = "0.5.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"] } 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..."); log::trace!("Creating Axum router...");
let app = axum::Router::new() 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!("Axum router created successfully!");
log::trace!("Creating Tokio listener..."); log::trace!("Creating Tokio listener...");

View file

@ -1,8 +1,16 @@
#[allow(unreachable_code)] use axum_extra::extract::Query;
pub async fn inbox_handler() { use serde::Deserialize;
todo!("pre-validation hook");
todo!("validate signature"); #[derive(Debug, Clone, Deserialize)]
todo!("post-validation hook"); pub struct WebfingerQuery {
todo!("database storage"); pub resource: String,
todo!("post-storage hook");
#[serde(default)]
pub rel: Vec<String>,
}
pub async fn webfinger_handler(
Query(WebfingerQuery {resource, rel}): Query<WebfingerQuery>
) {
todo!()
} }