示例#1
0
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
}
示例#2
0
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
}
示例#3
0
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
}
示例#4
0
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
}
示例#5
0
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
}