Add LoggingHTTPHandler for logging REST requests at the server-side
This commit is contained in:
1 parent
f08148cabb
commit
9dd1fbba39
2 files changed
+19
-1
No files matched your search
@@ -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}
|
||||||
|
}
|
||||||
+1
-1
@@ -293,7 +293,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
router.HandleHTTP(muxRouter)
|
router.HandleHTTP(muxRouter)
|
||||||
HandleHTTP(muxRouter, version, router, allocator, defaultSubnet, ns, dnsserver)
|
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)
|
Log.Println("Listening for HTTP control messages on", httpAddr)
|
||||||
go listenAndServeHTTP(httpAddr, muxRouter)
|
go listenAndServeHTTP(httpAddr, muxRouter)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user