diff options
author | 2016-12-20 18:58:05 +0000 | |
---|---|---|
committer | 2016-12-20 18:58:05 +0000 | |
commit | c4ab98c6e336a1c39b3934bbb3bf691f849a6dbe (patch) | |
tree | 89d801ac1484232179bcb7c144f67b5945221367 /middleware/metrics/handler.go | |
parent | 451a0bd5294f6c8a6c9c725c75ac1a9cbc996a42 (diff) | |
download | coredns-c4ab98c6e336a1c39b3934bbb3bf691f849a6dbe.tar.gz coredns-c4ab98c6e336a1c39b3934bbb3bf691f849a6dbe.tar.zst coredns-c4ab98c6e336a1c39b3934bbb3bf691f849a6dbe.zip |
Add middleware.NextOrFailure (#462)
This checks if the next middleware to be called is nil, and if so returns
ServerFailure and an error. This makes the next calling more robust and
saves some lines of code.
Also prefix the error with the name of the middleware to aid in
debugging.
Diffstat (limited to 'middleware/metrics/handler.go')
-rw-r--r-- | middleware/metrics/handler.go | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/middleware/metrics/handler.go b/middleware/metrics/handler.go index 11998165e..8b8f4d419 100644 --- a/middleware/metrics/handler.go +++ b/middleware/metrics/handler.go @@ -23,7 +23,7 @@ func (m *Metrics) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg // Record response to get status code and size of the reply. rw := dnsrecorder.New(w) - status, err := m.Next.ServeDNS(ctx, rw, r) + status, err := middleware.NextOrFailure(m.Name(), m.Next, ctx, rw, r) vars.Report(state, zone, rcode.ToString(rw.Rcode), rw.Len, rw.Start) |