github.com/artisanhe/tools@v1.0.1-0.20210607022958-19a8fef2eb04/courier/httpx/client_ip.go (about)

     1  package httpx
     2  
     3  import (
     4  	"strings"
     5  )
     6  
     7  func GetClientIPByHeaderForwardedFor(headerForwardedFor string) string {
     8  	if index := strings.IndexByte(headerForwardedFor, ','); index >= 0 {
     9  		return headerForwardedFor[0:index]
    10  	}
    11  	return strings.TrimSpace(headerForwardedFor)
    12  }
    13  
    14  func GetClientIPByHeaderRealIP(headerRealIP string) string {
    15  	return strings.TrimSpace(headerRealIP)
    16  }