middleware/whoami: add (#264)
Add a new middleware that tells you who you are; IP, port and transport is echoed back. Also some various cleanup and documentation improvements while at it: * ResponseWriter: improve the documentation of these helper functions. * And add an NextHandler for use in tests. Make chaos_test.go and * whoam_test.go use it.
This commit is contained in:
parent
ed907d3327
commit
30fd224504
10 changed files with 219 additions and 10 deletions
|
@ -26,21 +26,21 @@ func TestChaos(t *testing.T) {
|
|||
expectedErr error
|
||||
}{
|
||||
{
|
||||
next: genHandler(dns.RcodeSuccess, nil),
|
||||
next: test.NextHandler(dns.RcodeSuccess, nil),
|
||||
qname: "version.bind",
|
||||
expectedCode: dns.RcodeSuccess,
|
||||
expectedReply: version,
|
||||
expectedErr: nil,
|
||||
},
|
||||
{
|
||||
next: genHandler(dns.RcodeSuccess, nil),
|
||||
next: test.NextHandler(dns.RcodeSuccess, nil),
|
||||
qname: "authors.bind",
|
||||
expectedCode: dns.RcodeSuccess,
|
||||
expectedReply: "Miek Gieben",
|
||||
expectedErr: nil,
|
||||
},
|
||||
{
|
||||
next: genHandler(dns.RcodeSuccess, nil),
|
||||
next: test.NextHandler(dns.RcodeSuccess, nil),
|
||||
qname: "authors.bind",
|
||||
qtype: dns.TypeSRV,
|
||||
expectedCode: dns.RcodeSuccess,
|
||||
|
@ -77,10 +77,4 @@ func TestChaos(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func genHandler(rcode int, err error) middleware.Handler {
|
||||
return middleware.HandlerFunc(func(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) {
|
||||
return rcode, err
|
||||
})
|
||||
}
|
||||
|
||||
const version = "CoreDNS-001"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue