diff --git a/main.go b/main.go index 92be0c2..0b4ba8d 100644 --- a/main.go +++ b/main.go @@ -33,6 +33,7 @@ var ( type response struct { Success bool `json:"success"` + Error error `json:"error,omitempty"` MatchedRules yara.MatchRules `json:"rules,omitempty"` } @@ -168,8 +169,7 @@ func scanHandler(w http.ResponseWriter, r *http.Request) { log.WithField("match", m).Debug("Matched rules") if err != nil { - w.WriteHeader(http.StatusInternalServerError) - w.Write([]byte(err.Error())) + json.NewEncoder(w).Encode(response{Success: false, Error: err}) } else { json.NewEncoder(w).Encode(response{Success: true, MatchedRules: *m}) }