Skip to content

Commit

Permalink
ignore in failure handler
Browse files Browse the repository at this point in the history
  • Loading branch information
calmh committed Jun 2, 2024
1 parent 5ffa984 commit bade8d2
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions cmd/stcrashreceiver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func main() {
}

if params.DSN != "" {
mux.HandleFunc("/newcrash/failure", handleFailureFn(params.DSN, filepath.Join(params.Dir, "failure_reports")))
mux.HandleFunc("/newcrash/failure", handleFailureFn(params.DSN, filepath.Join(params.Dir, "failure_reports"), ip))
}

log.SetOutput(os.Stdout)
Expand All @@ -106,7 +106,7 @@ func main() {
}
}

func handleFailureFn(dsn, failureDir string) func(w http.ResponseWriter, req *http.Request) {
func handleFailureFn(dsn, failureDir string, ignore *ignorePatterns) func(w http.ResponseWriter, req *http.Request) {
return func(w http.ResponseWriter, req *http.Request) {
result := "failure"
defer func() {
Expand All @@ -121,6 +121,11 @@ func handleFailureFn(dsn, failureDir string) func(w http.ResponseWriter, req *ht
return
}

if ignore.match(bs) {
result = "ignored"
return
}

var reports []ur.FailureReport
err = json.Unmarshal(bs, &reports)
if err != nil {
Expand Down

0 comments on commit bade8d2

Please sign in to comment.