coredns/middleware/autopath/nonwriter.go
Miek Gieben b46b9880bd WIP: autopath as middleware (#859)
autopath as middleware
2017-08-09 03:13:38 -07:00

22 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 }