coredns/middleware/proxy/setup.go
Yong Tang ed907d3327 Fix proxy upstream parser issue and add test cases (#263)
This fix tries to fix 261 where proxy upstream parser is not
able to parse upstream correctly.

Several test cases have also been added to cover the changes
and prevent regression in the future.

This fix fixes 261.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2016-09-17 07:49:35 +01:00

27 lines
570 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 dnsserver.Handler) dnsserver.Handler {
return Proxy{Next: next, Client: Clients(), Upstreams: upstreams}
})
return nil
}