code: func getIp(r *http.Request) string {
  	for _, h := range []string{"X-Forwarded-For", "X-Real-Ip"} {
  		for _, ip := range strings.Split(r.Header.Get(h), ",") {
  			if len(ip) == 0 {
  				continue
  			}
  			realIP := net.ParseIP(strings.Replace(ip, " ", "", -1))
  			return realIP.String()
  		}
  	}
  
  	// not found in header
  	host, _, err := net.SplitHostPort(r.RemoteAddr)
  	if err != nil {
  		// just return remote addr
  		return r.RemoteAddr
  	}
  
  	return host
  }
docs: // getIp naively returns an ip for the request