package main import ( "encoding/json" "net/http" "strconv" ) func ReadLog(w http.ResponseWriter, r *http.Request) { log := MCServer.ReadAllLog() jsonData, _ := json.Marshal(log) sendJSONResponse(w, string(jsonData)) } func ReadLogFrom(w http.ResponseWriter, r *http.Request) { start, _ := mv(r, "start", false) startInt, _ := strconv.Atoi(start) end := MCServer.LenLog() //show only first 3000 record if start ~ end is >= 3000 if end-startInt > 3000 { startInt = end - 3000 } if startInt > MCServer.LenLog()-1 { sendJSONResponse(w, "[]") } else { log := MCServer.ReadRangeLog(startInt, end) jsonData, _ := json.Marshal(log) sendJSONResponse(w, string(jsonData)) } }