diff --git a/common/http.go b/common/http.go new file mode 100644 index 00000000..2f4a1b3c --- /dev/null +++ b/common/http.go @@ -0,0 +1,18 @@ +package common + +import ( + "net/http" +) + +type loggingHandler struct { + next http.Handler +} + +func (l *loggingHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { + Log.Debugf("[http] %s %s", r.Method, r.URL.RequestURI()) + l.next.ServeHTTP(w, r) +} + +func LoggingHTTPHandler(h http.Handler) http.Handler { + return &loggingHandler{next: h} +} diff --git a/prog/weaver/main.go b/prog/weaver/main.go index 816afacc..55d9815a 100644 --- a/prog/weaver/main.go +++ b/prog/weaver/main.go @@ -335,7 +335,7 @@ func main() { } router.HandleHTTP(muxRouter) HandleHTTP(muxRouter, version, router, allocator, defaultSubnet, ns, dnsserver) - http.Handle("/", muxRouter) + http.Handle("/", common.LoggingHTTPHandler(muxRouter)) Log.Println("Listening for HTTP control messages on", httpAddr) go listenAndServeHTTP(httpAddr) }