1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

fix: json serialization error when percentage is nan

This commit is contained in:
Ferdinand Mütsch
2020-10-16 15:16:43 +02:00
parent 67a59561c8
commit c575b2fd5c
2 changed files with 7 additions and 2 deletions

View File

@@ -2,6 +2,7 @@ package utils
import (
"encoding/json"
"log"
"net/http"
)
@@ -9,7 +10,7 @@ func RespondJSON(w http.ResponseWriter, status int, object interface{}) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(status)
if err := json.NewEncoder(w).Encode(object); err != nil {
w.WriteHeader(http.StatusInternalServerError)
log.Printf("error while writing json response: %v", err)
}
}