coredns-ldap/setup.go
Miek Gieben 1fb7424a47 Add example middleware
Serves both as documentation and to test external middleware
compilation.
2017-07-29 09:17:24 +01:00

29 lines
510 B
Go

package example
import (
"github.com/coredns/coredns/core/dnsserver"
"github.com/coredns/coredns/middleware"
"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() {
return middleware.Error("example", c.ArgErr())
}
dnsserver.GetConfig(c).AddMiddleware(func(next middleware.Handler) middleware.Handler {
return Example{Next: next}
})
return nil
}