b08a4a86 by 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]:****”
1 parent 3f0e55de
...@@ -98,7 +98,9 @@ func (input *BeegoInput) IP() string { ...@@ -98,7 +98,9 @@ func (input *BeegoInput) IP() string {
98 } 98 }
99 ip := strings.Split(input.Request.RemoteAddr, ":") 99 ip := strings.Split(input.Request.RemoteAddr, ":")
100 if len(ip) > 0 { 100 if len(ip) > 0 {
101 return ip[0] 101 if ip[0] != "["{
102 return ip[0]
103 }
102 } 104 }
103 return "127.0.0.1" 105 return "127.0.0.1"
104 } 106 }
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!