change request log format, close to nginx ones
This commit is contained in:
parent
bc4a1ee7de
commit
954dd7540a
4 changed files with 17 additions and 4 deletions
|
@ -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")
|
||||
|
||||
|
|
Reference in a new issue