refactor: move API routes to api.rs and remove unused imports

Co-authored-by: aider (openai/andrew/openrouter/qwen/qwen3-coder) <aider@aider.chat>
This commit is contained in:
Andrew Phillips
2025-08-12 14:50:14 -03:00
parent afdecb6c51
commit 4c82c55f58
2 changed files with 15 additions and 25 deletions

View File

@@ -5,24 +5,27 @@ use axum::{
use crate::modes::server::common::AppState;
use crate::modes::server::api::{
item, status, docs
item, status
};
use crate::modes::server::docs;
pub fn api_router() -> Router<AppState> {
Router::new()
// Status endpoints
.route("/api/status", get(status::handle_status))
.route("/status", get(status::handle_status))
// Item endpoints
.route("/api/item/", get(item::handle_list_items).post(item::handle_post_item))
.route("/api/item/latest", get(item::handle_get_item_latest))
.route("/api/item/latest/meta", get(item::handle_get_item_latest_meta))
.route("/api/item/latest/content", get(item::handle_get_content_latest).get(item::handle_get_content_latest_raw))
.route("/api/item/:id", get(item::handle_get_item).delete(item::handle_delete_item))
.route("/api/item/:id/meta", get(item::handle_get_item_meta))
.route("/api/item/:id/content", get(item::handle_get_content).get(item::handle_get_content_raw))
.route("/item/", get(item::handle_list_items).post(item::handle_post_item))
.route("/item/latest", get(item::handle_get_item_latest))
.route("/item/latest/meta", get(item::handle_get_item_latest_meta))
.route("/content", get(item::handle_get_content_latest))
.route("/content/:id", get(item::handle_get_content))
.route("/content-raw", get(item::handle_get_content_latest_raw))
.route("/content-raw/:id", get(item::handle_get_content_raw))
.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
.route("/api/openapi.json", get(docs::handle_openapi))
.route("/api/docs", get(docs::handle_swagger_ui))
.route("/openapi.json", get(docs::handle_openapi))
.route("/swagger/", get(docs::handle_swagger_ui))
}