diff options
Diffstat (limited to 'src/http.go')
-rw-r--r-- | src/http.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/http.go b/src/http.go index 6feeb33..480e356 100644 --- a/src/http.go +++ b/src/http.go @@ -37,6 +37,7 @@ func setupHTTPServer() (http.Server) { r.HandleFunc("/api/stopContainer", stopContainerHandler).Methods("POST") r.HandleFunc("/api/getAccess", getAccessHandler).Methods("GET") r.HandleFunc("/api/getTimeLimit", getTimeLimitHandler).Methods("GET") + r.HandleFunc("/api/getStats", getStatsHandler).Methods("GET") return http.Server{ Addr: fmt.Sprintf("0.0.0.0:%d", *port), @@ -203,6 +204,17 @@ func getChallengesHandler(w http.ResponseWriter, r *http.Request) { } } +func getStatsHandler(w http.ResponseWriter, r *http.Request) { + json, jsonErr := generateJSONFromChallengesForStats() + + if jsonErr == nil { + w.Write([]byte(json)) + } else { + log.Println(jsonErr) + w.WriteHeader(500) + } +} + func submitFlagHandler(w http.ResponseWriter, r *http.Request) { r.ParseForm() challengeName := r.Form.Get("challengeName") |