mirror of
				https://github.com/coredns/coredns.git
				synced 2025-11-03 18:53:13 -05:00 
			
		
		
		
	Add a new middleware that tells you who you are; IP, port and transport is echoed back. Also some various cleanup and documentation improvements while at it: * ResponseWriter: improve the documentation of these helper functions. * And add an NextHandler for use in tests. Make chaos_test.go and * whoam_test.go use it.
		
			
				
	
	
		
			20 lines
		
	
	
		
			396 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			20 lines
		
	
	
		
			396 B
		
	
	
	
		
			Go
		
	
	
	
	
	
package whoami
 | 
						|
 | 
						|
import (
 | 
						|
	"testing"
 | 
						|
 | 
						|
	"github.com/mholt/caddy"
 | 
						|
)
 | 
						|
 | 
						|
func TestSetupWhoami(t *testing.T) {
 | 
						|
	c := caddy.NewTestController("dns", `whoami`)
 | 
						|
	if err := setupWhoami(c); err != nil {
 | 
						|
		t.Fatalf("Expected no errors, but got: %v", err)
 | 
						|
	}
 | 
						|
 | 
						|
	c = caddy.NewTestController("dns", `whoami example.org`)
 | 
						|
	if err := setupWhoami(c); err == nil {
 | 
						|
		t.Fatalf("Expected errors, but got: %v", err)
 | 
						|
	}
 | 
						|
}
 |