// ExtractIP extracts request origin's IP address.
ExtractIP extracts request origin's IP address.
// ExtractIP extracts request origin ' s IP address .
func ExtractIP(r *http.Request) (net.IP, error) {
	ip := r.Header.Get("X-Real-IP")
	if ip == "" {
		ips := strings.Split(r.Header.Get("X-Forwarded-For"), ", ")
		ip = ips[len(ips)-1]
	}
	if ip == "" {
		ip, _, _ = net.SplitHostPort(r.RemoteAddr)
	}
	if ip == "" {
		return nil, NewError(nil, http.StatusBadRequest, "invalid ip address")
	}
	return net.ParseIP(ip), nil
}
func ExtractIP ( r * http . Request ) ( net . IP , error ) { ip := r . Header . Get ( " " ) if ip == " " { ips := strings . Split ( r . Header . Get ( " " ) , " " ) ip = ips [ len ( ips ) - 1 ] } if ip == " " { ip , _ , _ = net . SplitHostPort ( r . RemoteAddr ) } if ip == " " { return nil , NewError ( nil , http . StatusBadRequest , " " ) } return net . ParseIP ( ip ) , nil }
ExtractIP extracts request origin's IP address.
ExtractIP extracts request origin ' s IP address .