From 87a622b089f8dbce4b597d618d262bff60f557e6 Mon Sep 17 00:00:00 2001 From: HOKMA-TECH Date: Thu, 6 Aug 2026 10:58:01 -0300 Subject: [PATCH] feat(server): rota / com indice de endpoints --- server/src/api/mod.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/server/src/api/mod.rs b/server/src/api/mod.rs index e2864df..da5c4d1 100644 --- a/server/src/api/mod.rs +++ b/server/src/api/mod.rs @@ -6,10 +6,26 @@ pub mod search; pub mod stats; pub mod ws; -use axum::{routing::{get, post}, Router}; +use axum::{routing::{get, post}, Json, Router}; use tower_http::cors::CorsLayer; use crate::state::SharedState; +async fn index() -> Json { + Json(serde_json::json!({ + "service": "ares-next", + "version": env!("CARGO_PKG_VERSION"), + "endpoints": [ + "GET /api/v1/health", + "GET /api/v1/search?q=...", + "GET /api/v1/files/{file_id}", + "POST /api/v1/announce", + "GET /api/v1/peers/{file_id}", + "GET /api/v1/stats", + "WS /api/v1/tracker/ws" + ] + })) +} + pub fn router(state: SharedState) -> Router { let api = Router::new() .route("/health", get(health::health)) @@ -22,6 +38,7 @@ pub fn router(state: SharedState) -> Router { .with_state(state); Router::new() + .route("/", get(index)) .nest("/api/v1", api) .layer(CorsLayer::permissive()) } \ No newline at end of file