Skip to content
This repository was archived by the owner on May 21, 2025. It is now read-only.

Commit 2eab254

Browse files
authored
Merge pull request #140 from uded/client_ip_address
feat: client address (ip) in the http request directly
2 parents eb4965e + fde5929 commit 2eab254

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

core/request.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ func (r *RequestAccessor) EventToRequest(req events.APIGatewayProxyRequest) (*ht
190190
return nil, err
191191
}
192192

193+
httpRequest.RemoteAddr = req.RequestContext.Identity.SourceIP
194+
193195
if req.MultiValueHeaders != nil {
194196
for k, values := range req.MultiValueHeaders {
195197
for _, value := range values {

core/requestv2.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ func (r *RequestAccessorV2) EventToRequest(req events.APIGatewayV2HTTPRequest) (
123123

124124
path := req.RawPath
125125

126-
//if RawPath empty is, populate from request context
126+
// if RawPath empty is, populate from request context
127127
if len(path) == 0 {
128128
path = req.RequestContext.HTTP.Path
129129
}
@@ -164,6 +164,8 @@ func (r *RequestAccessorV2) EventToRequest(req events.APIGatewayV2HTTPRequest) (
164164
return nil, err
165165
}
166166

167+
httpRequest.RemoteAddr = req.RequestContext.HTTP.SourceIP
168+
167169
for _, cookie := range req.Cookies {
168170
httpRequest.Header.Add("Cookie", cookie)
169171
}

0 commit comments

Comments
 (0)