code refactor
This commit is contained in:
parent
94847d9059
commit
616674b643
|
@ -86,13 +86,13 @@ func configRoute(r *gin.Engine, version string) {
|
|||
r.POST("/prometheus/v1/query", stat(), queryPromql)
|
||||
|
||||
r.GET("/memory/alert-rule", alertRuleGet)
|
||||
r.GET("/memory/alert-rule-location", alertRuleLocationGet)
|
||||
r.GET("/memory/idents", identsGets)
|
||||
r.GET("/memory/alert-mutes", mutesGets)
|
||||
r.GET("/memory/alert-subscribes", subscribesGets)
|
||||
r.GET("/memory/target", targetGet)
|
||||
r.GET("/memory/user", userGet)
|
||||
r.GET("/memory/user-group", userGroupGet)
|
||||
r.GET("/memory/node/alert-rule", alertRuleNodeGet)
|
||||
|
||||
r.GET("/metrics", gin.WrapH(promhttp.Handler()))
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package router
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/toolkits/pkg/ginx"
|
||||
|
||||
|
@ -45,8 +47,13 @@ func userGroupGet(c *gin.Context) {
|
|||
c.JSON(200, gin.H{"id": id, "user_group": ug})
|
||||
}
|
||||
|
||||
func alertRuleNodeGet(c *gin.Context) {
|
||||
func alertRuleLocationGet(c *gin.Context) {
|
||||
id := ginx.QueryStr(c, "id")
|
||||
node, _ := naming.HashRing.GetNode(id)
|
||||
node, err := naming.HashRing.GetNode(id)
|
||||
if err != nil {
|
||||
http.Error(c.Writer, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(200, gin.H{"id": id, "node": node})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue