middleware/metrics: fix crash on startup (#318)

Make the methods that handle Metrics all use pointer receivers to fix
sync.Once not being initialized.

Finish the setup_test to test for failures. And make the check for the
address more strict and return an error when it does not have a port
number.

Add a toplevel test that starts a CoreDNS server with metrics enabled
so we catch these errors in the future.
This commit is contained in:
Miek Gieben 2016-10-04 11:05:04 +01:00 committed by GitHub
parent d914832904
commit db6c9a3f01
5 changed files with 53 additions and 16 deletions

View file

@ -13,7 +13,7 @@ import (
)
// ServeDNS implements the Handler interface.
func (m Metrics) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) {
func (m *Metrics) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) {
state := request.Request{W: w, Req: r}
qname := state.QName()