mirror of
https://github.com/coredns/coredns.git
synced 2025-10-28 00:34:24 -04:00
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.
This commit is contained in:
@@ -18,7 +18,7 @@ func (d Dnssec) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg)
|
||||
qtype := state.QType()
|
||||
zone := middleware.Zones(d.zones).Matches(qname)
|
||||
if zone == "" {
|
||||
return d.Next.ServeDNS(ctx, w, r)
|
||||
return middleware.NextOrFailure(d.Name(), d.Next, ctx, w, r)
|
||||
}
|
||||
|
||||
// Intercept queries for DNSKEY, but only if one of the zones matches the qname, otherwise we let
|
||||
@@ -36,7 +36,7 @@ func (d Dnssec) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg)
|
||||
}
|
||||
|
||||
drr := &ResponseWriter{w, d}
|
||||
return d.Next.ServeDNS(ctx, drr, r)
|
||||
return middleware.NextOrFailure(d.Name(), d.Next, ctx, drr, r)
|
||||
}
|
||||
|
||||
var (
|
||||
|
||||
Reference in New Issue
Block a user