Simple debug HTTP request logging
parent
1ff86556b7
commit
d8a836e618
|
@ -104,7 +104,7 @@ func NewClientHandler(server *etcdserver.EtcdServer) http.Handler {
|
||||||
mux.Handle(deprecatedMachinesPrefix, dmh)
|
mux.Handle(deprecatedMachinesPrefix, dmh)
|
||||||
handleSecurity(mux, sech)
|
handleSecurity(mux, sech)
|
||||||
|
|
||||||
return mux
|
return requestLogger(mux)
|
||||||
}
|
}
|
||||||
|
|
||||||
type keysHandler struct {
|
type keysHandler struct {
|
||||||
|
|
|
@ -78,3 +78,10 @@ func allowMethod(w http.ResponseWriter, m string, ms ...string) bool {
|
||||||
http.Error(w, "Method Not Allowed", http.StatusMethodNotAllowed)
|
http.Error(w, "Method Not Allowed", http.StatusMethodNotAllowed)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func requestLogger(handler http.Handler) http.Handler {
|
||||||
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
plog.Debugf("[%s] %s remote:%s", r.Method, r.RequestURI, r.RemoteAddr)
|
||||||
|
handler.ServeHTTP(w, r)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue