From cd7b83f69bf9c5b3374aaa45bf01a822297fc875 Mon Sep 17 00:00:00 2001 From: Sam Sneddon Date: Tue, 24 Sep 2024 22:40:53 -0700 Subject: [PATCH] Fix #4009: reorder the registration of routes (#4017) Per the mux docs, "Routes are tested in the order they were added to the router. If two routes match, the first one wins." This means that `checks.RegisterRoutes()` needs to be called after everything else defining a route in /api/checks/ as it otherwise matches every path under /api/checks/. --- webapp/web/main.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/webapp/web/main.go b/webapp/web/main.go index daaf06075b..d9920a9d53 100644 --- a/webapp/web/main.go +++ b/webapp/web/main.go @@ -18,15 +18,24 @@ import ( ) func init() { - // webapp.RegisterRoutes has a catch-all, so needs to go last. - api.RegisterRoutes() + // API routes: + + // /api/checks/ routes: azure.RegisterRoutes() - checks.RegisterRoutes() ghactions.RegisterRoutes() + // checks.RegisterRoutes has a catch-all for /api/checks/, so needs to go last. + checks.RegisterRoutes() + + // The rest of /api/: + api.RegisterRoutes() query.RegisterRoutes() receiver.RegisterRoutes() screenshot.RegisterRoutes() taskcluster.RegisterRoutes() + + // The actual Web App: + + // webapp.RegisterRoutes has a catch-all, so needs to go last. webapp.RegisterRoutes() }