Files
SentinelMesh/backend/src/routes/mod.rs
T
gilles 2a44301269 feat(backend): implémentation complète Phase 1
- Migration SQLite initiale : agents, devices, metrics, events
- API REST v1 complète : /agents, /network, /metrics, /events, /widgets
- Endpoints widgets Glance : /api/v1/widgets/network et /api/v1/widgets/metrics
- Spec OpenAPI générée et servie sur /api-docs/openapi.json
- Gestion d'erreurs centralisée (AppError)
- CORS permissif pour développement
- push réseau met à jour le last_seen de l'agent

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-19 06:09:02 +02:00

25 lines
992 B
Rust

use axum::{routing::get, Router};
use sqlx::SqlitePool;
pub mod agents;
pub mod events;
pub mod health;
pub mod metrics;
pub mod network;
pub mod widgets;
pub fn api_router(db: SqlitePool) -> Router {
Router::new()
.route("/api/v1/health", get(health::health))
.route("/api/v1/agents", get(agents::list).post(agents::register))
.route("/api/v1/agents/{id}", get(agents::get_one))
.route("/api/v1/network", get(network::list).post(network::push))
.route("/api/v1/network/{ip}", get(network::get_one))
.route("/api/v1/metrics", get(metrics::list).post(metrics::push))
.route("/api/v1/metrics/{agent_id}", get(metrics::get_one))
.route("/api/v1/events", get(events::list).post(events::push))
.route("/api/v1/widgets/network", get(widgets::network))
.route("/api/v1/widgets/metrics", get(widgets::metrics))
.with_state(db)
}