authorizer/server/utils/request_info.go

22 lines
447 B
Go
Raw Normal View History

package utils
import "net/http"
2022-01-17 06:02:13 +00:00
// GetIP helps in getting the IP address from the request
func GetIP(r *http.Request) string {
IPAddress := r.Header.Get("X-Real-Ip")
if IPAddress == "" {
IPAddress = r.Header.Get("X-Forwarded-For")
}
if IPAddress == "" {
IPAddress = r.RemoteAddr
}
return IPAddress
}
2022-01-17 06:02:13 +00:00
// GetUserAgent helps in getting the user agent from the request
func GetUserAgent(r *http.Request) string {
return r.UserAgent()
}