Minor refactor

This commit is contained in:
phoenix
2026-01-01 14:11:44 -05:00
parent 161d0da377
commit 08650619dc
+1 -2
View File
@@ -25,8 +25,7 @@ func InvalidJson(err error) string {
func RespondWithJSON(w http.ResponseWriter, statusCode int, data interface{}) { func RespondWithJSON(w http.ResponseWriter, statusCode int, data interface{}) {
w.Header().Set("Content-Type", "application/json") w.Header().Set("Content-Type", "application/json")
w.WriteHeader(statusCode) w.WriteHeader(statusCode)
encoder := json.NewEncoder(w) if err := json.NewEncoder(w).Encode(data); err != nil {
if err := encoder.Encode(data); err != nil {
log.Printf("Error encoding JSON: %v", err) log.Printf("Error encoding JSON: %v", err)
} }
} }