coredns/middleware/proxy/setup.go
Miek Gieben 54964653d1 middleware/proxy: add request duration monitoring (#362)
Add a separate request duration metrics specially for proxying requests
upstream.

Fixes #259
2016-10-28 12:54:49 +01:00

29 lines
599 B
Go

package proxy
import (
"github.com/miekg/coredns/core/dnsserver"
"github.com/miekg/coredns/middleware"
"github.com/mholt/caddy"
)
func init() {
caddy.RegisterPlugin("proxy", caddy.Plugin{
ServerType: "dns",
Action: setup,
})
}
func setup(c *caddy.Controller) error {
upstreams, err := NewStaticUpstreams(&c.Dispenser)
if err != nil {
return middleware.Error("proxy", err)
}
dnsserver.GetConfig(c).AddMiddleware(func(next middleware.Handler) middleware.Handler {
return Proxy{Next: next, Client: newClient(), Upstreams: upstreams}
})
c.OnStartup(OnStartup)
return nil
}