mirror of
				https://github.com/coredns/coredns.git
				synced 2025-11-03 02:33:21 -05:00 
			
		
		
		
	* 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>
		
			
				
	
	
		
			21 lines
		
	
	
		
			690 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			21 lines
		
	
	
		
			690 B
		
	
	
	
		
			Go
		
	
	
	
	
	
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
 | 
						|
}
 |