Handle X-Forwarded-For header in log

This commit is contained in:
nemunaire 2018-10-17 16:30:34 +02:00
parent 52686d369c
commit cb95df096d

View File

@ -105,6 +105,9 @@ func genStudents() map[string]map[string]*Submission {
}
func ServeJSON(w http.ResponseWriter, r *http.Request) {
if addr := r.Header.Get("X-Forwarded-For"); addr != "" {
r.RemoteAddr = addr
}
log.Printf("Handling %s request from %s: %s [%s]\n", r.Method, r.RemoteAddr, r.URL.Path, r.UserAgent())
w.Header().Set("Content-Type", "application/json")
@ -146,6 +149,9 @@ func genStudent(login string) map[string]*Submission {
}
func ServeJSONStudent(w http.ResponseWriter, r *http.Request) {
if addr := r.Header.Get("X-Forwarded-For"); addr != "" {
r.RemoteAddr = addr
}
log.Printf("Handling %s request from %s: %s [%s]\n", r.Method, r.RemoteAddr, r.URL.Path, r.UserAgent())
w.Header().Set("Content-Type", "application/json")