Minor refactor
This commit is contained in:
@@ -25,8 +25,7 @@ func InvalidJson(err error) string {
|
||||
func RespondWithJSON(w http.ResponseWriter, statusCode int, data interface{}) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(statusCode)
|
||||
encoder := json.NewEncoder(w)
|
||||
if err := encoder.Encode(data); err != nil {
|
||||
if err := json.NewEncoder(w).Encode(data); err != nil {
|
||||
log.Printf("Error encoding JSON: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user