Skip to content

Commit

Permalink
debug rule routes register allows nil
Browse files Browse the repository at this point in the history
  • Loading branch information
xgfone committed Dec 11, 2024
1 parent 7061703 commit fbe1d01
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion http/router/ruler/builder_debug_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,19 @@ func (b RouteBuilder) DebugVars() RouteBuilder {
}

// DebugRuleRoutes registers the rule-routes route with the path "/debug/router/rule/routes".
//
// If router is nil, use DefaultRouter instead.
func (b RouteBuilder) DebugRuleRoutes(router *Router) RouteBuilder {
return b.Path("/debug/router/rule/routes").GETContext(func(c *reqresp.Context) {
c.JSON(200, map[string]interface{}{"routes": router.Routes()})
var response struct {
Routes []Route `json:"routes"`
}
if router == nil {
response.Routes = DefaultRouter.Routes()
} else {
response.Routes = router.Routes()
}
c.JSON(200, response)
})
}

Expand Down

0 comments on commit fbe1d01

Please sign in to comment.