16 lines
276 B
Go
16 lines
276 B
Go
|
package otherthings
|
||
|
|
||
|
import (
|
||
|
"net/http"
|
||
|
)
|
||
|
|
||
|
// Thanks random StackOverflow answerer
|
||
|
|
||
|
func GetUserIP(r *http.Request) string {
|
||
|
IPAddress := r.Header.Get("X-REAL-IP")
|
||
|
if IPAddress == "" {
|
||
|
IPAddress = r.Header.Get("X-FORWARDED-FOR")
|
||
|
}
|
||
|
return IPAddress
|
||
|
}
|