refactor: restructure API routes with /api prefix and update content endpoint paths

This commit is contained in:
Andrew Phillips
2025-08-12 15:02:21 -03:00
committed by Andrew Phillips (aider)
parent 68c5514a44
commit 25b70492bc

View File

@@ -9,21 +9,19 @@ use crate::modes::server::api::{
}; };
use crate::modes::server::docs; use crate::modes::server::docs;
pub fn api_router() -> Router<AppState> { pub fn add_routes(router: Router<AppState>) -> Router<AppState> {
Router::new() router
// Status endpoints // Status endpoints
.route("/status", get(status::handle_status)) .route("/api/status", get(status::handle_status))
// Item endpoints // Item endpoints
.route("/item/", get(item::handle_list_items).post(item::handle_post_item)) .route("/api/item/", get(item::handle_list_items).post(item::handle_post_item))
.route("/item/latest", get(item::handle_get_item_latest)) .route("/api/item/latest", get(item::handle_get_item_latest))
.route("/item/latest/meta", get(item::handle_get_item_latest_meta)) .route("/api/item/latest/meta", get(item::handle_get_item_latest_meta))
.route("/content", get(item::handle_get_content_latest)) .route("/api/item/latest/content", get(item::handle_get_content_latest))
.route("/content/:id", get(item::handle_get_content)) .route("/api/item/:id", get(item::handle_get_item).delete(item::handle_delete_item))
.route("/content-raw", get(item::handle_get_content_latest_raw)) .route("/api/item/:id/meta", get(item::handle_get_item_meta))
.route("/content-raw/:id", get(item::handle_get_content_raw)) .route("/api/item/:id/content", get(item::handle_get_content))
.route("/item/:id", get(item::handle_get_item).delete(item::handle_delete_item))
.route("/item/:id/meta", get(item::handle_get_item_meta))
// Documentation endpoints // Documentation endpoints
.route("/openapi.json", get(docs::handle_openapi)) .route("/openapi.json", get(docs::handle_openapi))