MCPcopy Create free account
hub / github.com/feiyu563/PrometheusAlert / AddRouter

Method AddRouter

controllers/WebAlertRouter.go:65–90  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

63}
64
65func (c *MainController) AddRouter() {
66 if !CheckAccount(c.Ctx) {
67 c.Redirect("/login", 302)
68 return
69 }
70 WebAlertRouterJson := AlertRouterJson{}
71 logsign := "[" + LogsSign() + "]"
72 logs.Info(logsign, string(c.Ctx.Input.RequestBody))
73 json.Unmarshal(c.Ctx.Input.RequestBody, &WebAlertRouterJson)
74 rules, err := json.Marshal(WebAlertRouterJson.Rules)
75 if WebAlertRouterJson.RouterId == "" {
76 tpl_id_int, _ := strconv.Atoi(WebAlertRouterJson.RouterTplId)
77 err = models.AddAlertRouter(0, tpl_id_int, WebAlertRouterJson.RouterName, string(rules), WebAlertRouterJson.RouterPurl, WebAlertRouterJson.RouterPat, WebAlertRouterJson.RouterPatRR, WebAlertRouterJson.RouterSendResolved)
78 } else {
79 id, _ := strconv.Atoi(WebAlertRouterJson.RouterId)
80 tpl_id_int, _ := strconv.Atoi(WebAlertRouterJson.RouterTplId)
81 err = models.UpdateAlertRouter(id, tpl_id_int, WebAlertRouterJson.RouterName, string(rules), WebAlertRouterJson.RouterPurl, WebAlertRouterJson.RouterPat, WebAlertRouterJson.RouterPatRR, WebAlertRouterJson.RouterSendResolved)
82 }
83 var resp interface{}
84 resp = err
85 if err != nil {
86 resp = err.Error()
87 }
88 c.Data["json"] = resp
89 c.ServeJSON()
90}
91
92// router edit
93func (c *MainController) RouterEdit() {

Callers

nothing calls this directly

Calls 5

AddAlertRouterFunction · 0.92
UpdateAlertRouterFunction · 0.92
CheckAccountFunction · 0.85
LogsSignFunction · 0.85
stringFunction · 0.85

Tested by

no test coverage detected