mirror of
				https://github.com/coredns/coredns.git
				synced 2025-10-31 10:13:14 -04:00 
			
		
		
		
	
		
			
				
	
	
		
			23 lines
		
	
	
		
			576 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			23 lines
		
	
	
		
			576 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package autopath
 | |
| 
 | |
| import (
 | |
| 	"github.com/miekg/dns"
 | |
| )
 | |
| 
 | |
| // NonWriter is a type of ResponseWriter that captures the message, but never writes to the client.
 | |
| type NonWriter struct {
 | |
| 	dns.ResponseWriter
 | |
| 	Msg *dns.Msg
 | |
| }
 | |
| 
 | |
| // NewNonWriter makes and returns a new NonWriter.
 | |
| func NewNonWriter(w dns.ResponseWriter) *NonWriter { return &NonWriter{ResponseWriter: w} }
 | |
| 
 | |
| // WriteMsg records the message, but doesn't write it itself.
 | |
| func (r *NonWriter) WriteMsg(res *dns.Msg) error {
 | |
| 	r.Msg = res
 | |
| 	return nil
 | |
| }
 | |
| 
 | |
| func (r *NonWriter) Write(buf []byte) (int, error) { return len(buf), nil }
 |