Commit b08a4a86 authored by Max Lau's avatar Max Lau

repaired the wrong IP when using in localhost (Mac os x)

it returns “[“ when using beego in local host(Mac os x 10.9) , it
appears that Request.remoAddr returns “[::1]:****”
parent 3f0e55de
...@@ -98,7 +98,9 @@ func (input *BeegoInput) IP() string { ...@@ -98,7 +98,9 @@ func (input *BeegoInput) IP() string {
} }
ip := strings.Split(input.Request.RemoteAddr, ":") ip := strings.Split(input.Request.RemoteAddr, ":")
if len(ip) > 0 { if len(ip) > 0 {
return ip[0] if ip[0] != "["{
return ip[0]
}
} }
return "127.0.0.1" return "127.0.0.1"
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment