mirror of
				https://github.com/coredns/coredns.git
				synced 2025-11-03 18:53:13 -05: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:
		@@ -6,7 +6,6 @@ import (
 | 
			
		||||
	"net"
 | 
			
		||||
	"strconv"
 | 
			
		||||
 | 
			
		||||
	"github.com/miekg/coredns/middleware"
 | 
			
		||||
	"github.com/miekg/coredns/request"
 | 
			
		||||
 | 
			
		||||
	"github.com/miekg/dns"
 | 
			
		||||
@@ -15,9 +14,7 @@ import (
 | 
			
		||||
 | 
			
		||||
// Whoami is a middleware that returns your IP address, port and the protocol used for connecting
 | 
			
		||||
// to CoreDNS.
 | 
			
		||||
type Whoami struct {
 | 
			
		||||
	Next middleware.Handler
 | 
			
		||||
}
 | 
			
		||||
type Whoami struct{}
 | 
			
		||||
 | 
			
		||||
// ServeDNS implements the middleware.Handler interface.
 | 
			
		||||
func (wh Whoami) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user