INNER CODE UNIT · Go
clientIPForForwardedRequest
kite-org/kite · main_test.go:87
func clientIPForForwardedRequest(t *testing.T, trustedProxies []string, remoteAddr, forwardedFor string) string {
t.Helper()
gin.SetMode(gin.TestMode)
oldTrustedProxies := common.TrustedProxies
t.Cleanup(func() {
common.TrustedProxies = oldTrustedProxies
})
if trustedProxies != nil {
common.TrustedProxies = trustedProxies
}
r := gin.New()
configureTrustedProxies(r)
r.GET("/client-ip", func(c *gin.Context) {
c.String(http.StatusOK, c.ClientIP())
})