General refactoring. Part 2.

This commit is contained in:
Manu Mtz-Almeida
2014-10-09 01:40:42 +02:00
parent 030706c39a
commit aa7b00a083
7 changed files with 163 additions and 147 deletions
+11
View File
@@ -197,6 +197,17 @@ func (c *Context) MustGet(key string) interface{} {
return value
}
func (c *Context) ClientIP() string {
clientIP := c.Request.Header.Get("X-Real-IP")
if len(clientIP) == 0 {
clientIP = c.Request.Header.Get("X-Forwarded-For")
}
if len(clientIP) == 0 {
clientIP = c.Request.RemoteAddr
}
return clientIP
}
/************************************/
/********* PARSING REQUEST **********/
/************************************/