golang-lib/http/main.go

12 lines
170 B
Go
Raw Normal View History

2017-05-29 22:53:51 +02:00
package http
import "net/http"
func GetRemoteIP(r *http.Request) string {
ip := r.Header.Get("X-Forwarded-For")
if len(ip) <= 1 {
ip = r.RemoteAddr
}
return ip
}