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) } }
func jsonTestHandler(w traffic.ResponseWriter, r *traffic.Request) { data := map[string]string{ "foo": "bar", } w.WriteJSON(data) }
func (api *ImgServerApi) statsHandler(w traffic.ResponseWriter, r *traffic.Request) { w.WriteJSON(api.imageCache.Stats()) }