mirror of
				https://github.com/coredns/coredns.git
				synced 2025-10-31 18:23:13 -04:00 
			
		
		
		
	* Rename middleware to plugin first pass; mostly used 'sed', few spots where I manually changed text. This still builds a coredns binary. * fmt error * Rename AddMiddleware to AddPlugin * Readd AddMiddleware to remain backwards compat
		
			
				
	
	
		
			24 lines
		
	
	
		
			676 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			24 lines
		
	
	
		
			676 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| // Package loadbalance is plugin for rewriting responses to do "load balancing"
 | |
| package loadbalance
 | |
| 
 | |
| import (
 | |
| 	"github.com/coredns/coredns/plugin"
 | |
| 
 | |
| 	"github.com/miekg/dns"
 | |
| 	"golang.org/x/net/context"
 | |
| )
 | |
| 
 | |
| // RoundRobin is plugin to rewrite responses for "load balancing".
 | |
| type RoundRobin struct {
 | |
| 	Next plugin.Handler
 | |
| }
 | |
| 
 | |
| // ServeDNS implements the plugin.Handler interface.
 | |
| func (rr RoundRobin) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) {
 | |
| 	wrr := &RoundRobinResponseWriter{w}
 | |
| 	return plugin.NextOrFailure(rr.Name(), rr.Next, ctx, wrr, r)
 | |
| }
 | |
| 
 | |
| // Name implements the Handler interface.
 | |
| func (rr RoundRobin) Name() string { return "loadbalance" }
 |