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
|
## Name
|
||||||
|
|
||||||
*example* - prints "example" on every query received.
|
*example* - prints "example" on every query handled.
|
||||||
|
|
||||||
## Description
|
## Description
|
||||||
|
|
||||||
The example plugin prints "example" on every query received. It serves as documentation for
|
The example plugin prints "example" on every query that go handled by the server. It serves as
|
||||||
writing CoreDNS plugins.
|
documentation for writing CoreDNS plugins.
|
||||||
|
|
||||||
## Syntax
|
## 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.
|
// WriteMsg calls the underlying ResponseWriter's WriteMsg method and prints "example" to standard output.
|
||||||
func (r *ResponsePrinter) WriteMsg(res *dns.Msg) error {
|
func (r *ResponsePrinter) WriteMsg(res *dns.Msg) error {
|
||||||
fmt.Fprintln(out, ex)
|
fmt.Fprintln(out, "example")
|
||||||
return r.ResponseWriter.WriteMsg(res)
|
return r.ResponseWriter.WriteMsg(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make out a reference to os.Stdout so we can easily overwrite it for testing.
|
// Make out a reference to os.Stdout so we can easily overwrite it for testing.
|
||||||
var out io.Writer = os.Stdout
|
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.
|
// Call our plugin directly, and check the result.
|
||||||
x.ServeDNS(ctx, rec, r)
|
x.ServeDNS(ctx, rec, r)
|
||||||
if a := b.String(); a != ex+"\n" {
|
if a := b.String(); a != "example\n" {
|
||||||
t.Errorf("Failed to print '%s', got %s", ex, a)
|
t.Errorf("Failed to print '%s', got %s", example, a)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user