Пример #1
0
func (s AlertManagerService) getSilence(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
	silence, err := s.Silencer.GetSilence(manager.SilenceID(getID(p)))
	if err != nil {
		http.Error(w, fmt.Sprint("Error getting silence: ", err), http.StatusNotFound)
		return
	}

	respondJSON(w, &silence)
}
Пример #2
0
func (s AlertManagerService) updateSilence(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
	sc := manager.Silence{}
	if err := parseJSON(w, r, &sc); err != nil {
		return
	}
	// BUG: add server-side form validation.
	sc.ID = manager.SilenceID(getID(p))
	if err := s.Silencer.UpdateSilence(&sc); err != nil {
		http.Error(w, fmt.Sprint("Error updating silence: ", err), http.StatusNotFound)
		return
	}
}
Пример #3
0
func (s AlertManagerService) deleteSilence(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
	if err := s.Silencer.DelSilence(manager.SilenceID(getID(p))); err != nil {
		http.Error(w, fmt.Sprint("Error deleting silence: ", err), http.StatusNotFound)
		return
	}
}