Skip to content

Commit

Permalink
Golint
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurenceJJones committed Jan 29, 2024
1 parent 148c725 commit 12ecbab
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions router/router.go
Expand Up @@ -251,15 +251,15 @@ func (fs *onlyImageFS) Open(name string) (http.File, error) {

func useXRealIP(trustedProxy bool, inner gin.LogFormatter) gin.LogFormatter {
return func(params gin.LogFormatterParams) string {
params.ClientIP = getClientIp(trustedProxy, params.Request)
params.ClientIP = getClientIP(trustedProxy, params.Request)
return inner(params)
}
}

func getClientIp(trustedProxy bool, req *http.Request) string {
func getClientIP(trustedProxy bool, req *http.Request) string {
if trustedProxy {
realIpParts := strings.SplitN(req.Header.Get("x-real-ip"), ",", 2)
if ip := strings.TrimSpace(realIpParts[0]); ip != "" {
realIPParts := strings.SplitN(req.Header.Get("x-real-ip"), ",", 2)
if ip := strings.TrimSpace(realIPParts[0]); ip != "" {
return ip
}
}
Expand Down

0 comments on commit 12ecbab

Please sign in to comment.