Skip to content

Commit

Permalink
Merge pull request #686 from luraproject/remote_ip_headers
Browse files Browse the repository at this point in the history
Do not replace the default gin value if there's no remote_ip_headers …
  • Loading branch information
taik0 authored Sep 28, 2023
2 parents ae01c04 + 005d77b commit 8afdf3a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions router/gin/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,15 @@ func NewEngine(cfg config.ServiceConfig, opt EngineOptions) *gin.Engine {
if ginOptions.ForwardedByClientIP != nil {
engine.ForwardedByClientIP = *ginOptions.ForwardedByClientIP
}
engine.RemoteIPHeaders = ginOptions.RemoteIPHeaders
for k, h := range engine.RemoteIPHeaders {
engine.RemoteIPHeaders[k] = textproto.CanonicalMIMEHeaderKey(h)
if len(ginOptions.RemoteIPHeaders) > 0 {
engine.RemoteIPHeaders = ginOptions.RemoteIPHeaders
for k, h := range engine.RemoteIPHeaders {
engine.RemoteIPHeaders[k] = textproto.CanonicalMIMEHeaderKey(h)
}
}
if len(ginOptions.TrustedProxies) > 0 {
engine.SetTrustedProxies(ginOptions.TrustedProxies)
}
engine.SetTrustedProxies(ginOptions.TrustedProxies)
engine.AppEngine = ginOptions.AppEngine
engine.MaxMultipartMemory = ginOptions.MaxMultipartMemory
engine.RemoveExtraSlash = ginOptions.RemoveExtraSlash
Expand Down

0 comments on commit 8afdf3a

Please sign in to comment.