refactor: Simplify server router merging with conditional compilation

Co-authored-by: aider (openai/andrew/openrouter/sonoma-sky-alpha) <aider@aider.chat>
This commit is contained in:
Andrew Phillips
2025-09-10 10:00:30 -03:00
parent 8f3f6c05db
commit 39c3375cf5
2 changed files with 22 additions and 14 deletions

View File

@@ -56,7 +56,7 @@ use utoipa_swagger_ui::SwaggerUi;
struct ApiDoc;
pub fn add_routes(router: Router<AppState>) -> Router<AppState> {
router
let mut router = router
// Status endpoints
.route("/api/status", get(status::handle_status))
@@ -65,11 +65,14 @@ pub fn add_routes(router: Router<AppState>) -> Router<AppState> {
.route("/api/item/latest/meta", get(item::handle_get_item_latest_meta))
.route("/api/item/latest/content", get(item::handle_get_item_latest_content))
.route("/api/item/{item_id}/meta", get(item::handle_get_item_meta))
.route("/api/item/{item_id}/content", get(item::handle_get_item_content))
// MCP endpoints
#[cfg(feature = "mcp")]
.route("/mcp/sse", get(mcp::handle_mcp_sse))
.route("/api/item/{item_id}/content", get(item::handle_get_item_content));
#[cfg(feature = "mcp")]
{
router = router.route("/mcp/sse", get(mcp::handle_mcp_sse));
}
router
}
pub fn add_docs_routes(router: Router<AppState>) -> Router<AppState> {