diff --git a/server/handler/fallback.go b/server/handler/fallback.go index 22b3f19..3334b50 100644 --- a/server/handler/fallback.go +++ b/server/handler/fallback.go @@ -3,6 +3,7 @@ package handler import ( "bytes" "encoding/json" + "fmt" "io" "net/http" ) @@ -20,7 +21,12 @@ func (h *Handler) Fallback(w http.ResponseWriter, r *http.Request) { // Pretty-print JSON to console var prettyJSON bytes.Buffer if err := json.Indent(&prettyJSON, body, "", " "); err != nil { - http.Error(w, "Invalid JSON", http.StatusBadRequest) + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(http.StatusBadRequest) + json.NewEncoder(w).Encode(map[string]string{ + "status": "ERROR", + "message": fmt.Sprintf("Invalid JSON received. Visit /about for more info."), + }) return }