mirror of
https://github.com/coredns/coredns.git
synced 2025-11-01 18:53:43 -04:00
plugin/view: Advanced routing interface and new 'view' plugin (#5538)
* introduce new interface "dnsserver.Viewer", that allows a plugin implementing it to decide if a query should be routed into its server block. * add new plugin "view", that uses the new interface to enable a user to define expression based conditions that must be met for a query to be routed to its server block. Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
This commit is contained in:
20
core/dnsserver/view.go
Normal file
20
core/dnsserver/view.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package dnsserver
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/coredns/coredns/request"
|
||||
)
|
||||
|
||||
// Viewer - If Viewer is implemented by a plugin in a server block, its Filter()
|
||||
// is added to the server block's filter functions when starting the server. When a running server
|
||||
// serves a DNS request, it will route the request to the first Config (server block) that passes
|
||||
// all its filter functions.
|
||||
type Viewer interface {
|
||||
// Filter returns true if the server should use the server block in which the implementing plugin resides, and the
|
||||
// name of the view for metrics logging.
|
||||
Filter(ctx context.Context, req *request.Request) bool
|
||||
|
||||
// ViewName returns the name of the view
|
||||
ViewName() string
|
||||
}
|
||||
Reference in New Issue
Block a user