From 9524c0ca7a4bb0b6ae9f81587cf3deee8a03b045 Mon Sep 17 00:00:00 2001 From: Patrick Sullivan Date: Thu, 2 Jan 2025 22:43:33 -0600 Subject: [PATCH] fix: v2 alert APIs (#5563) Try to match on the v2 alert endpoints in the router **before** the v1 endpoints. If we try to match on the v1 endpoints first then a call to a v2 endpoint such as `GET: /api/v2/my-org/alerts` will actually match with the v1 endpoint `GET: /api/{org_id}/alerts` where `v2` will be bound to `{org_id}`. If we swap the matching order then requests to v2 endpoints will be correctly routed to v2 endpoints and requests to v1 endpoints will be correctly routed to v1 endpoints. ## Summary by CodeRabbit - **Refactor** - Reorganized alert-related service routes in the application - Removed and re-added existing alert service routes without changing their core functionality --- src/handler/http/router/mod.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/handler/http/router/mod.rs b/src/handler/http/router/mod.rs index 09f0b8c523..d8652e9c9f 100644 --- a/src/handler/http/router/mod.rs +++ b/src/handler/http/router/mod.rs @@ -433,6 +433,13 @@ pub fn get_service_routes(cfg: &mut web::ServiceConfig) { .service(folders::deprecated::update_folder) .service(folders::deprecated::get_folder) .service(folders::deprecated::delete_folder) + .service(alerts::create_alert) + .service(alerts::get_alert) + .service(alerts::update_alert) + .service(alerts::delete_alert) + .service(alerts::list_alerts) + .service(alerts::enable_alert) + .service(alerts::trigger_alert) .service(alerts::deprecated::save_alert) .service(alerts::deprecated::update_alert) .service(alerts::deprecated::get_alert) @@ -441,13 +448,6 @@ pub fn get_service_routes(cfg: &mut web::ServiceConfig) { .service(alerts::deprecated::delete_alert) .service(alerts::deprecated::enable_alert) .service(alerts::deprecated::trigger_alert) - .service(alerts::create_alert) - .service(alerts::get_alert) - .service(alerts::update_alert) - .service(alerts::delete_alert) - .service(alerts::list_alerts) - .service(alerts::enable_alert) - .service(alerts::trigger_alert) .service(alerts::templates::save_template) .service(alerts::templates::update_template) .service(alerts::templates::get_template)