mirror of
				https://github.com/coredns/coredns.git
				synced 2025-10-31 10:13:14 -04:00 
			
		
		
		
	Cleanup: put middleware helper functions in pkgs (#245)
Move all (almost all) Go files in middleware into their own packages. This makes for better naming and discoverability. Lot of changes elsewhere to make this change. The middleware.State was renamed to request.Request which is better, but still does not cover all use-cases. It was also moved out middleware because it is used by `dnsserver` as well. A pkg/dnsutil packages was added for shared, handy, dns util functions. All normalize functions are now put in normalize.go
This commit is contained in:
		| @@ -9,6 +9,8 @@ import ( | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/miekg/coredns/middleware" | ||||
| 	"github.com/miekg/coredns/middleware/pkg/roller" | ||||
| 	"github.com/miekg/coredns/request" | ||||
|  | ||||
| 	"github.com/miekg/dns" | ||||
| 	"golang.org/x/net/context" | ||||
| @@ -19,7 +21,7 @@ type ErrorHandler struct { | ||||
| 	Next      middleware.Handler | ||||
| 	LogFile   string | ||||
| 	Log       *log.Logger | ||||
| 	LogRoller *middleware.LogRoller | ||||
| 	LogRoller *roller.LogRoller | ||||
| 	Debug     bool // if true, errors are written out to client rather than to a log | ||||
| } | ||||
|  | ||||
| @@ -29,7 +31,7 @@ func (h ErrorHandler) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns | ||||
| 	rcode, err := h.Next.ServeDNS(ctx, w, r) | ||||
|  | ||||
| 	if err != nil { | ||||
| 		state := middleware.State{W: w, Req: r} | ||||
| 		state := request.Request{W: w, Req: r} | ||||
| 		errMsg := fmt.Sprintf("%s [ERROR %d %s %s] %v", time.Now().Format(timeFormat), rcode, state.Name(), state.Type(), err) | ||||
|  | ||||
| 		if h.Debug { | ||||
| @@ -53,7 +55,7 @@ func (h ErrorHandler) recovery(ctx context.Context, w dns.ResponseWriter, r *dns | ||||
| 		return | ||||
| 	} | ||||
|  | ||||
| 	state := middleware.State{W: w, Req: r} | ||||
| 	state := request.Request{W: w, Req: r} | ||||
| 	// Obtain source of panic | ||||
| 	// From: https://gist.github.com/swdunlop/9629168 | ||||
| 	var name, file string // function name, file name | ||||
|   | ||||
		Reference in New Issue
	
	Block a user