diff --git a/cmd/helloserver/main.go b/cmd/helloserver/main.go index fb81a86..feae031 100644 --- a/cmd/helloserver/main.go +++ b/cmd/helloserver/main.go @@ -30,5 +30,9 @@ func handle(w http.ResponseWriter, r *http.Request) { hn, _ := os.Hostname() fmt.Fprintf(w, "Served by %s running %s\n", hn, runtime.GOOS) fmt.Fprintf(w, "Hit count: %d", hits.Inc()) - log.Printf("Hit from %s: %s", r.Header.Get("X-Remote-Ip"), r.RequestURI) + + ip := r.Header.Get("X-Remote-Ip") + if ip != "" { + log.Printf("Hit from %s: %s", ip, r.RequestURI) + } }