Fix for latest coredns
This commit is contained in:
parent
4d14b01c84
commit
fe5e8f02ad
@ -4,15 +4,14 @@ package example
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/coredns/coredns/middleware"
|
"github.com/coredns/coredns/plugin"
|
||||||
|
|
||||||
"github.com/miekg/dns"
|
"github.com/miekg/dns"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Example is an example middleware to ...
|
// Example is an example middleware to ...
|
||||||
type Example struct {
|
type Example struct {
|
||||||
Next middleware.Handler
|
Next plugin.Handler
|
||||||
}
|
}
|
||||||
|
|
||||||
// ServeDNS implements the middleware.Handler interface.
|
// ServeDNS implements the middleware.Handler interface.
|
||||||
@ -21,7 +20,7 @@ func (e Example) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg)
|
|||||||
// the next middleware - but as an example, show how to wrap a ResponseWriter might be
|
// the next middleware - but as an example, show how to wrap a ResponseWriter might be
|
||||||
// educational.
|
// educational.
|
||||||
pw := NewResponsePrinter(w)
|
pw := NewResponsePrinter(w)
|
||||||
return middleware.NextOrFailure(e.Name(), e.Next, ctx, pw, r)
|
return plugin.NextOrFailure(e.Name(), e.Next, ctx, pw, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Name implements the Handler interface.
|
// Name implements the Handler interface.
|
||||||
|
6
setup.go
6
setup.go
@ -2,7 +2,7 @@ package example
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/coredns/coredns/core/dnsserver"
|
"github.com/coredns/coredns/core/dnsserver"
|
||||||
"github.com/coredns/coredns/middleware"
|
"github.com/coredns/coredns/plugin"
|
||||||
|
|
||||||
"github.com/mholt/caddy"
|
"github.com/mholt/caddy"
|
||||||
)
|
)
|
||||||
@ -17,10 +17,10 @@ func init() {
|
|||||||
func setup(c *caddy.Controller) error {
|
func setup(c *caddy.Controller) error {
|
||||||
c.Next()
|
c.Next()
|
||||||
if c.NextArg() {
|
if c.NextArg() {
|
||||||
return middleware.Error("example", c.ArgErr())
|
return plugin.Error("example", c.ArgErr())
|
||||||
}
|
}
|
||||||
|
|
||||||
dnsserver.GetConfig(c).AddMiddleware(func(next middleware.Handler) middleware.Handler {
|
dnsserver.GetConfig(c).AddPlugin(func(next plugin.Handler) plugin.Handler {
|
||||||
return Example{Next: next}
|
return Example{Next: next}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user