refactor: rename method to reflect use-case

This commit is contained in:
Stefan Bildl 2023-03-25 15:02:48 +01:00
parent a889c58de7
commit fc3aee84b5
2 changed files with 3 additions and 3 deletions

View File

@ -796,7 +796,7 @@ func (c *Context) ClientIP() string {
if trusted && c.engine.ForwardedByClientIP && c.engine.RemoteIPHeaders != nil {
for _, headerName := range c.engine.RemoteIPHeaders {
ip, valid := c.engine.validateHeader(c.requestHeader(headerName))
ip, valid := c.engine.getTrustedClientIP(c.requestHeader(headerName))
if valid {
return ip
}

4
gin.go
View File

@ -454,8 +454,8 @@ func (engine *Engine) isTrustedProxy(ip net.IP) bool {
return false
}
// validateHeader will parse X-Forwarded-For header and return the trusted client IP address
func (engine *Engine) validateHeader(header string) (clientIP string, valid bool) {
// getTrustedClientIP will parse X-Forwarded-For header and return the trusted client IP address
func (engine *Engine) getTrustedClientIP(header string) (clientIP string, valid bool) {
if header == "" {
return "", false
}