From 5530f397798e6b0f35bbf03d167e99ce93a09120 Mon Sep 17 00:00:00 2001 From: kieran Date: Thu, 30 Jan 2025 22:25:56 +0000 Subject: [PATCH] fix: head void_cat_redirect --- src/bin/main.rs | 2 +- src/routes/mod.rs | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/bin/main.rs b/src/bin/main.rs index add9594..10446c6 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -73,7 +73,7 @@ async fn main() -> Result<(), Error> { .attach(Shield::new()) // disable .mount( "/", - routes![root, get_blob, head_blob, routes::void_cat_redirect], + routes![root, get_blob, head_blob, routes::void_cat_redirect, routes::void_cat_redirect_head], ) .mount("/admin", routes::admin_routes()); diff --git a/src/routes/mod.rs b/src/routes/mod.rs index dcd9aa2..d64d75d 100644 --- a/src/routes/mod.rs +++ b/src/routes/mod.rs @@ -451,3 +451,24 @@ pub async fn void_cat_redirect(id: &str, settings: &State) -> Option")] +pub async fn void_cat_redirect_head(id: &str) -> VoidCatFile { + let id = if id.contains(".") { + id.split('.').next().unwrap() + } else { + id + }; + let uuid = + uuid::Uuid::from_slice_le(nostr::bitcoin::base58::decode(id).unwrap().as_slice()).unwrap(); + VoidCatFile { + status: Status::Ok, + uuid: Header::new("X-UUID", uuid.to_string()), + } +} + +#[derive(Responder)] +pub struct VoidCatFile { + pub status: Status, + pub uuid: Header<'static>, +}