mirror of
https://github.com/coredns/coredns.git
synced 2025-11-02 10:13:14 -05:00
22
middleware/autopath/nonwriter.go
Normal file
22
middleware/autopath/nonwriter.go
Normal file
@@ -0,0 +1,22 @@
|
||||
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 }
|
||||
Reference in New Issue
Block a user