func ListRuns(w http.ResponseWriter, r *http.Request) { runsList := models.GetRunListSorted() offset := r.FormValue("offset") length := r.FormValue("length") if offset == "" { offset = "-1" } if length == "" { length = "-1" } o, err := strconv.Atoi(offset) if err != nil { http.Error(w, err.Error(), http.StatusBadRequest) return } l, err := strconv.Atoi(length) if err != nil { http.Error(w, err.Error(), http.StatusBadRequest) return } recent := runsList.GetRecent(o, l) marshal(recent, w) }
// TODO: Move to handlers package when more websocket handling is required. func getRecentRuns() []byte { runsList := models.GetRunListSorted() recent := runsList.GetRecent(0, 10) bytes, err := json.Marshal(recent) if err != nil { panic(err.Error()) } return bytes }