Fix generated JSON in case of error

This commit is contained in:
nemunaire 2017-10-26 14:14:54 +02:00 committed by Pierre-Olivier Mercier
commit 137286006d
3 changed files with 3 additions and 3 deletions

View file

@ -25,7 +25,7 @@ func (t TimeHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
if j, err := json.Marshal(timeObject{ChallengeStart.Unix(), time.Now().Unix(), int(ChallengeEnd.Sub(ChallengeStart).Seconds())}); err != nil {
http.Error(w, fmt.Sprintf("{\"errmsg\":\"%q\"}", err), http.StatusInternalServerError)
http.Error(w, fmt.Sprintf("{\"errmsg\":%q}", err), http.StatusInternalServerError)
} else {
w.WriteHeader(http.StatusOK)
w.Write(j)