summaryrefslogtreecommitdiff
path: root/client/gitlabnet.go
diff options
context:
space:
mode:
Diffstat (limited to 'client/gitlabnet.go')
-rw-r--r--client/gitlabnet.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/client/gitlabnet.go b/client/gitlabnet.go
index 31131d2..c34f148 100644
--- a/client/gitlabnet.go
+++ b/client/gitlabnet.go
@@ -41,6 +41,9 @@ type ApiError struct {
Msg string
}
+// To use as the key in a Context to set an X-Forwarded-For header in a request
+type OriginalRemoteIPContextKey struct{}
+
func (e *ApiError) Error() string {
return e.Msg
}
@@ -150,6 +153,11 @@ func (c *GitlabNetClient) DoRequest(ctx context.Context, method, path string, da
}
request.Header.Set(apiSecretHeaderName, tokenString)
+ originalRemoteIP, ok := ctx.Value(OriginalRemoteIPContextKey{}).(string)
+ if ok {
+ request.Header.Add("X-Forwarded-For", originalRemoteIP)
+ }
+
request.Header.Add("Content-Type", "application/json")
request.Header.Add("User-Agent", c.userAgent)
request.Close = true