From 40550e76a9f7e08167179b81f6c08b8f58c2b64a Mon Sep 17 00:00:00 2001 From: ale <ale@incal.net> Date: Mon, 19 Oct 2020 14:01:35 +0100 Subject: [PATCH] Log unmatched requests --- collector.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/collector.go b/collector.go index f90447a..7323243 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 { -- GitLab