diff options
author | 2016-12-20 18:58:05 +0000 | |
---|---|---|
committer | 2016-12-20 18:58:05 +0000 | |
commit | c4ab98c6e336a1c39b3934bbb3bf691f849a6dbe (patch) | |
tree | 89d801ac1484232179bcb7c144f67b5945221367 /middleware/loadbalance/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/loadbalance/handler.go')
-rw-r--r-- | middleware/loadbalance/handler.go | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/middleware/loadbalance/handler.go b/middleware/loadbalance/handler.go index 9f9cfb766..9b4baf2ed 100644 --- a/middleware/loadbalance/handler.go +++ b/middleware/loadbalance/handler.go @@ -16,7 +16,7 @@ type RoundRobin struct { // ServeDNS implements the middleware.Handler interface. func (rr RoundRobin) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) { wrr := &RoundRobinResponseWriter{w} - return rr.Next.ServeDNS(ctx, wrr, r) + return middleware.NextOrFailure(rr.Name(), rr.Next, ctx, wrr, r) } // Name implements the Handler interface. |