2017-07-29 08:17:24 +00:00
|
|
|
package example
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/coredns/coredns/core/dnsserver"
|
2017-09-15 20:29:47 +00:00
|
|
|
"github.com/coredns/coredns/plugin"
|
2017-07-29 08:17:24 +00:00
|
|
|
|
|
|
|
"github.com/mholt/caddy"
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
caddy.RegisterPlugin("example", caddy.Plugin{
|
|
|
|
ServerType: "dns",
|
|
|
|
Action: setup,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func setup(c *caddy.Controller) error {
|
|
|
|
c.Next()
|
|
|
|
if c.NextArg() {
|
2017-09-15 20:29:47 +00:00
|
|
|
return plugin.Error("example", c.ArgErr())
|
2017-07-29 08:17:24 +00:00
|
|
|
}
|
|
|
|
|
2017-09-15 20:29:47 +00:00
|
|
|
dnsserver.GetConfig(c).AddPlugin(func(next plugin.Handler) plugin.Handler {
|
2017-07-29 08:17:24 +00:00
|
|
|
return Example{Next: next}
|
|
|
|
})
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|