feat(server): rota / com indice de endpoints
This commit is contained in:
+18
-1
@@ -6,10 +6,26 @@ pub mod search;
|
|||||||
pub mod stats;
|
pub mod stats;
|
||||||
pub mod ws;
|
pub mod ws;
|
||||||
|
|
||||||
use axum::{routing::{get, post}, Router};
|
use axum::{routing::{get, post}, Json, Router};
|
||||||
use tower_http::cors::CorsLayer;
|
use tower_http::cors::CorsLayer;
|
||||||
use crate::state::SharedState;
|
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"
|
||||||
|
]
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
pub fn router(state: SharedState) -> Router {
|
pub fn router(state: SharedState) -> Router {
|
||||||
let api = Router::new()
|
let api = Router::new()
|
||||||
.route("/health", get(health::health))
|
.route("/health", get(health::health))
|
||||||
@@ -22,6 +38,7 @@ pub fn router(state: SharedState) -> Router {
|
|||||||
.with_state(state);
|
.with_state(state);
|
||||||
|
|
||||||
Router::new()
|
Router::new()
|
||||||
|
.route("/", get(index))
|
||||||
.nest("/api/v1", api)
|
.nest("/api/v1", api)
|
||||||
.layer(CorsLayer::permissive())
|
.layer(CorsLayer::permissive())
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user