login performance optimization

This commit is contained in:
landaiqing
2024-08-25 00:06:00 +08:00
parent 974a96b6e0
commit 6e47e72514
8 changed files with 149 additions and 145 deletions

15
utils/get_ip.go Normal file
View File

@@ -0,0 +1,15 @@
package utils
import "github.com/gin-gonic/gin"
// GetClientIP 工具函数获取客户端IP
func GetClientIP(c *gin.Context) string {
ip := c.GetHeader("X-Real-IP")
if ip == "" {
ip = c.GetHeader("X-Forwarded-For")
}
if ip == "" {
ip = c.ClientIP()
}
return ip
}