mirror of
https://github.com/pomerium/pomerium.git
synced 2025-04-29 18:36:30 +02:00
14 lines
315 B
Go
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]
|
|
}
|