func removeDestination(w http.ResponseWriter, r *http.Request) (interface{}, *handlerError) { key := mux.Vars(r)["key"] index := mux.Vars(r)["index"] idx, _ := strconv.Atoi(index) err := table.DelDestination(key, idx) if err != nil { return nil, &handlerError{nil, "Could not find entry " + key + "/" + index, http.StatusNotFound} } return make(map[string]string), nil }
func removeRoute(w http.ResponseWriter, r *http.Request) (interface{}, *handlerError) { key := mux.Vars(r)["key"] err := table.DelRoute(key) if err != nil { return nil, &handlerError{nil, "Could not find entry " + key, http.StatusNotFound} } return make(map[string]string), nil }
func getRoute(w http.ResponseWriter, r *http.Request) (interface{}, *handlerError) { key := mux.Vars(r)["key"] route := table.GetRoute(key) if route == nil { return nil, &handlerError{nil, "Could not find route " + key, http.StatusNotFound} } return route, nil }
func removeAggregator(w http.ResponseWriter, r *http.Request) (interface{}, *handlerError) { index := mux.Vars(r)["index"] idx, _ := strconv.Atoi(index) err := table.DelAggregator(idx) if err != nil { return nil, &handlerError{nil, err.Error(), http.StatusNotFound} } return make(map[string]string), nil }
func badMetricsHandler(w http.ResponseWriter, r *http.Request) (interface{}, *handlerError) { timespec := mux.Vars(r)["timespec"] duration, err := time.ParseDuration(timespec) if err != nil { return nil, &handlerError{err, "Could not parse timespec", http.StatusBadRequest} } records := badMetrics.Get(duration) return records, nil }