Skip to content

Commit

Permalink
Fix #4009: reorder the registration of routes (#4017)
Browse files Browse the repository at this point in the history
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/.
  • Loading branch information
gsnedders authored Sep 25, 2024
1 parent efe4987 commit cd7b83f
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions webapp/web/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down

0 comments on commit cd7b83f

Please sign in to comment.