Allow the use of cloudflare IP

This commit is contained in:
George Shammas 2016-07-19 23:00:05 +00:00
parent e3d1bc7bed
commit 9d6ff7803a
1 changed files with 4 additions and 0 deletions

View File

@ -25,6 +25,10 @@ func Logger() gin.HandlerFunc {
if err != nil {
c.Abort()
}
cfIP := net.ParseIP(c.Request.Header.Get("CF-Connecting-IP"))
if cfIP != nil {
ip.IP = cfIP
}
// before request
c.Next()