12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- package example
- import (
- "github.com/coredns/coredns/core/dnsserver"
- "github.com/coredns/coredns/plugin"
- "github.com/coredns/coredns/plugin/metrics"
- "github.com/caddyserver/caddy"
- )
- func init() {
- caddy.RegisterPlugin("example", caddy.Plugin{
- ServerType: "dns",
- Action: setup,
- })
- }
- func setup(c *caddy.Controller) error {
- c.Next()
- if c.NextArg() {
-
-
-
- return plugin.Error("example", c.ArgErr())
- }
-
-
-
- c.OnStartup(func() error {
- once.Do(func() { metrics.MustRegister(c, requestCount) })
- return nil
- })
-
- dnsserver.GetConfig(c).AddPlugin(func(next plugin.Handler) plugin.Handler {
- return Example{Next: next}
- })
-
- return nil
- }
|