diff --git a/collector.go b/collector.go index f90447a79aa6f33ef1d5d9968b806a1bd5a327b7..732324310794f2f52ad94f23f18224a267c06be5 100644 --- a/collector.go +++ b/collector.go @@ -57,6 +57,7 @@ func (c *Collector) ServeHTTP(w http.ResponseWriter, req *http.Request) { // Find a handler that can successfully parse the request, and // get a list of Events. var events []Event + matched := false hloop: for _, h := range c.handlers { var err error @@ -65,15 +66,22 @@ hloop: case ErrNoMatch: continue case nil: + matched = true w.WriteHeader(http.StatusOK) break hloop default: - log.Printf("error parsing report: %v", err) + log.Printf("error parsing report (%s): %v", ct, err) http.Error(w, err.Error(), http.StatusBadRequest) return } } + if !matched { + log.Printf("no matching handlers for \"%s\"", ct) + http.Error(w, "No matching handlers", http.StatusBadRequest) + return + } + // Augment the Events with additional information obtained // from the HTTP request, and send them to the forwarder. for _, e := range events {