change request log format, close to nginx ones

This commit is contained in:
nemunaire 2017-12-17 15:42:33 +01:00
parent bc4a1ee7de
commit 954dd7540a
4 changed files with 17 additions and 4 deletions

View file

@ -20,7 +20,10 @@ type timeObject struct {
}
func (t TimeHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
log.Printf("Handling %s request from %s: %s [%s]\n", r.Method, r.RemoteAddr, r.URL.Path, r.UserAgent())
if addr := r.Header.Get("X-Forwarded-For"); addr != "" {
r.RemoteAddr = addr
}
log.Printf("%s \"%s %s\" [%s]\n", r.RemoteAddr, r.Method, r.URL.Path, r.UserAgent())
w.Header().Set("Content-Type", "application/json")