1
0
Fork 0
mirror of https://github.com/pomerium/pomerium.git synced 2025-05-29 08:57:18 +02:00
pomerium/internal/httputil/ip.go
2023-05-01 15:11:30 -04:00

14 lines
315 B
Go

package httputil
import (
"net/http"
"strings"
)
// GetClientIP returns the client IP address from the request.
func GetClientIP(r *http.Request) string {
if clientIP := r.Header.Get("X-Forwarded-For"); clientIP != "" {
return strings.Split(clientIP, ",")[0]
}
return strings.Split(r.RemoteAddr, ":")[0]
}