Small tweaks to the code

Signed-off-by: Miek Gieben <miek@miek.nl>
This commit is contained in:
Miek Gieben 2019-08-15 09:18:00 +01:00
parent 42b98af7f9
commit 9132b485e3
3 changed files with 6 additions and 9 deletions

View File

@ -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

View File

@ -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"

View File

@ -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)
}
}