mirror of
				https://github.com/coredns/coredns.git
				synced 2025-10-31 02:03:20 -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:
		| @@ -23,7 +23,7 @@ type Chaos struct { | ||||
| func (c Chaos) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) { | ||||
| 	state := request.Request{W: w, Req: r} | ||||
| 	if state.QClass() != dns.ClassCHAOS || state.QType() != dns.TypeTXT { | ||||
| 		return c.Next.ServeDNS(ctx, w, r) | ||||
| 		return middleware.NextOrFailure(c.Name(), c.Next, ctx, w, r) | ||||
| 	} | ||||
|  | ||||
| 	m := new(dns.Msg) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user