feat(server): pagina HTML na raiz

This commit is contained in:
2026-08-06 11:05:30 -03:00
parent 87a622b089
commit f31241b967
+37 -14
View File
@@ -7,23 +7,46 @@ pub mod stats;
pub mod ws;
use axum::{routing::{get, post}, Json, Router};
use axum::response::Html;
use tower_http::cors::CorsLayer;
use crate::state::SharedState;
async fn index() -> Json<serde_json::Value> {
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"
]
}))
async fn index() -> Html<&'static str> {
Html(r#"<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Ares Next</title>
<style>
body { font-family: system-ui, -apple-system, sans-serif; margin: 0; background: #0f1115; color: #e6e6e6; display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.card { background: #181c24; border: 1px solid #2a2f3a; border-radius: 12px; padding: 40px 48px; max-width: 520px; width: 90%; }
h1 { margin: 0 0 8px; font-size: 28px; }
.status { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 13px; background: #123c2a; color: #4ade80; font-weight: 600; }
p.muted { color: #9aa3b2; margin: 8px 0 20px; }
ul { list-style: none; padding: 0; margin: 0; }
li { padding: 7px 10px; border-bottom: 1px solid #232833; font-family: ui-monospace, monospace; font-size: 14px; }
li:last-child { border-bottom: none; }
.tag { color: #7dd3fc; }
</style>
</head>
<body>
<div class="card">
<h1>Ares Next</h1>
<span class="status">online</span>
<p class="muted">Tracker P2P + busca de arquivos por hash — API pública</p>
<ul>
<li><span class="tag">GET</span> /api/v1/health</li>
<li><span class="tag">GET</span> /api/v1/search?q=...</li>
<li><span class="tag">GET</span> /api/v1/files/{file_id}</li>
<li><span class="tag">POST</span> /api/v1/announce</li>
<li><span class="tag">GET</span> /api/v1/peers/{file_id}</li>
<li><span class="tag">GET</span> /api/v1/stats</li>
<li><span class="tag">WS</span> /api/v1/tracker/ws</li>
</ul>
</div>
</body>
</html>"#)
}
pub fn router(state: SharedState) -> Router {