Allow custom forwarded for header

This commit is contained in:
Manuel de Brito Fontes 2017-09-07 18:11:23 -03:00
parent 6146bc4dc2
commit c24e212aac
3 changed files with 21 additions and 7 deletions

View file

@ -157,6 +157,7 @@ var (
},
"buildAuthSignURL": buildAuthSignURL,
"isValidClientBodyBufferSize": isValidClientBodyBufferSize,
"buildForwardedFor": buildForwardedFor,
}
)
@ -640,3 +641,14 @@ func getIngressInformation(i, p interface{}) *ingressInformation {
return info
}
func buildForwardedFor(input interface{}) string {
s, ok := input.(string)
if !ok {
glog.Errorf("expected an string type but %T was returned", input)
}
ffh := strings.Replace(s, "-", "_", -1)
ffh = strings.ToLower(ffh)
return fmt.Sprintf("$http_%v", ffh)
}