Пример #1
0
func (api *ImgServerApi) listHandler(w traffic.ResponseWriter, r *traffic.Request) {

	age, err := strconv.Atoi(r.Param("age"))
	if err != nil {
		age = 0
	}

	files, err := api.imageDir.ListFiles(time.Duration(age) * time.Second)
	if err != nil {
		traffic.Logger().Print(err.Error())
		w.WriteHeader(http.StatusInternalServerError)
	} else {
		w.WriteJSON(files)
	}
}
Пример #2
0
func jsonTestHandler(w traffic.ResponseWriter, r *traffic.Request) {
	data := map[string]string{
		"foo": "bar",
	}
	w.WriteJSON(data)
}
Пример #3
0
func (api *ImgServerApi) statsHandler(w traffic.ResponseWriter, r *traffic.Request) {

	w.WriteJSON(api.imageCache.Stats())
}