github.com/profzone/eden-framework@v1.0.10/pkg/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 }