change request log format, close to nginx ones
This commit is contained in:
parent
838918da66
commit
edc6ca9b7a
4 changed files with 17 additions and 4 deletions
|
@ -19,7 +19,10 @@ type DispatchFunction func(httprouter.Params, []byte) (interface{}, error)
|
||||||
|
|
||||||
func apiHandler(f DispatchFunction) func(http.ResponseWriter, *http.Request, httprouter.Params) {
|
func apiHandler(f DispatchFunction) func(http.ResponseWriter, *http.Request, httprouter.Params) {
|
||||||
return func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
return func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
||||||
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")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
|
||||||
|
|
|
@ -24,13 +24,17 @@ const resolutiontpl = `<!DOCTYPE html>
|
||||||
`
|
`
|
||||||
|
|
||||||
func (s ResolutionHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
func (s ResolutionHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
|
if addr := r.Header.Get("X-Forwarded-For"); addr != "" {
|
||||||
|
r.RemoteAddr = addr
|
||||||
|
}
|
||||||
|
|
||||||
if !enableResolutionRoute {
|
if !enableResolutionRoute {
|
||||||
log.Printf("UNHANDELED %s request from %s: /resolution%s [%s]\n", r.Method, r.RemoteAddr, r.URL.Path, r.UserAgent())
|
log.Printf("UNHANDELED %s request from %s: /resolution%s [%s]\n", r.Method, r.RemoteAddr, r.URL.Path, r.UserAgent())
|
||||||
http.NotFound(w, r)
|
http.NotFound(w, r)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("Handling %s request from %s: /resolution%s [%s]\n", r.Method, r.RemoteAddr, r.URL.Path, r.UserAgent())
|
log.Printf("%s \"%s /resolution%s\" [%s]\n", r.RemoteAddr, r.Method, r.URL.Path, r.UserAgent())
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "text/html")
|
w.Header().Set("Content-Type", "text/html")
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,10 @@ type submissionTeamChecker struct{
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c submissionChecker) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
func (c submissionChecker) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
log.Printf("Handling %s %s request from %s: %s [%s]\n", r.Method, c.kind, 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 [%s]\n", r.RemoteAddr, r.Method, r.URL.Path, c.kind, r.UserAgent())
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,10 @@ type timeObject struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t TimeHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
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")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
|
||||||
|
|
Reference in a new issue