Small tweaks to the code
Signed-off-by: Miek Gieben <miek@miek.nl>
This commit is contained in:
parent
42b98af7f9
commit
9132b485e3
@ -2,12 +2,12 @@
|
||||
|
||||
## Name
|
||||
|
||||
*example* - prints "example" on every query received.
|
||||
*example* - prints "example" on every query handled.
|
||||
|
||||
## Description
|
||||
|
||||
The example plugin prints "example" on every query received. It serves as documentation for
|
||||
writing CoreDNS plugins.
|
||||
The example plugin prints "example" on every query that go handled by the server. It serves as
|
||||
documentation for writing CoreDNS plugins.
|
||||
|
||||
## Syntax
|
||||
|
||||
|
@ -61,12 +61,9 @@ func NewResponsePrinter(w dns.ResponseWriter) *ResponsePrinter {
|
||||
|
||||
// WriteMsg calls the underlying ResponseWriter's WriteMsg method and prints "example" to standard output.
|
||||
func (r *ResponsePrinter) WriteMsg(res *dns.Msg) error {
|
||||
fmt.Fprintln(out, ex)
|
||||
fmt.Fprintln(out, "example")
|
||||
return r.ResponseWriter.WriteMsg(res)
|
||||
}
|
||||
|
||||
// Make out a reference to os.Stdout so we can easily overwrite it for testing.
|
||||
var out io.Writer = os.Stdout
|
||||
|
||||
// What we will print.
|
||||
const ex = "example"
|
||||
|
@ -29,7 +29,7 @@ func TestExample(t *testing.T) {
|
||||
|
||||
// Call our plugin directly, and check the result.
|
||||
x.ServeDNS(ctx, rec, r)
|
||||
if a := b.String(); a != ex+"\n" {
|
||||
t.Errorf("Failed to print '%s', got %s", ex, a)
|
||||
if a := b.String(); a != "example\n" {
|
||||
t.Errorf("Failed to print '%s', got %s", example, a)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user