From bb279afc927b073087c177a8bc621a6ae4cb1eff Mon Sep 17 00:00:00 2001 From: dawn <90008@gaze.systems> Date: Thu, 16 Apr 2026 00:17:50 +0300 Subject: [PATCH] [api] fix index page to show indexer if compiled with indexer --- src/api/index.txt | 4 ++-- src/api/mod.rs | 25 +++++++++++++++++-------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/api/index.txt b/src/api/index.txt index 9ba09e4..e609ca0 100644 --- a/src/api/index.txt +++ b/src/api/index.txt @@ -9,6 +9,6 @@ d8' d8' -this is an atproto relay instance, running the hydrant (https://tangled.org/ptr.pet/hydrant) implementation. +this is an atproto %type% instance, running the hydrant (https://tangled.org/ptr.pet/hydrant) implementation. -subscribe to the relay at: /xrpc/com.atproto.sync.subscribeRepos +subscribe to the %type% at: %subscribe_url% diff --git a/src/api/mod.rs b/src/api/mod.rs index 7ad95a5..716da79 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -20,16 +20,27 @@ mod stream; mod xrpc; pub async fn serve(hydrant: Hydrant, port: u16) -> miette::Result<()> { - #[allow(unused_mut)] - let mut app = Router::new() - .route("/", get(async || include_str!("index.txt"))) + let app = Router::new() + .route( + "/", + get(async || { + let kind = cfg!(feature = "indexer") + .then_some("indexer") + .unwrap_or("relay"); + let subscribe = cfg!(feature = "indexer") + .then_some("/stream") + .unwrap_or("/xrpc/com.atproto.sync.subscribeRepos"); + include_str!("index.txt") + .replace("%type%", kind) + .replace("%subscribe_url%", subscribe) + }), + ) .route("/health", get(async || "OK")) .route("/_health", get(async || "OK")) .route("/stats", get(stats::get_stats)); #[cfg(feature = "indexer")] let app = app.nest("/stream", stream::router()); - #[allow(unused_mut)] - let mut app = app + let app = app .merge(xrpc::router()) .merge(filter::router()) .merge(pds::router()) @@ -39,9 +50,7 @@ pub async fn serve(hydrant: Hydrant, port: u16) -> miette::Result<()> { .merge(db::router()); #[cfg(feature = "indexer")] - { - app = app.merge(crawler::router()); - } + let app = app.merge(crawler::router()); #[cfg(feature = "backlinks")] let app = app.merge(crate::backlinks::api::router()); -- 2.51.2