config+server: Check for errors and handle them
continuous-integration/drone/push Build is passing Details

master
Luther Wen Xu 2020-04-23 16:23:21 +07:00
parent 81e74807f4
commit 05395032be
Signed by: chanbakjsd
GPG Key ID: B7D77E3E9D102B70
2 changed files with 6 additions and 3 deletions

@ -16,6 +16,6 @@ func ReadConfig(file string) (Config, error) {
return Config{}, err
}
var result Config
json.Unmarshal(bytes, &result)
return result, nil
err = json.Unmarshal(bytes, &result)
return result, err
}

@ -11,7 +11,10 @@ func writeJSON(w http.ResponseWriter, a interface{}) {
http.Error(w, "500 Internal Server Error", http.StatusInternalServerError)
}
w.Header().Set("Content-Type", "application/json")
w.Write(bytes)
_, err = w.Write(bytes)
if err != nil {
http.Error(w, "500 Internal Server Error", http.StatusInternalServerError)
}
}
func allStatus(w http.ResponseWriter, req *http.Request) {