Skip to content

Commit

Permalink
Merge pull request awslabs#140 from uded/client_ip_address
Browse files Browse the repository at this point in the history
feat: client address (ip) in the http request directly
  • Loading branch information
sapessi authored Aug 9, 2022
2 parents eb4965e + fde5929 commit 2eab254
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions core/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ func (r *RequestAccessor) EventToRequest(req events.APIGatewayProxyRequest) (*ht
return nil, err
}

httpRequest.RemoteAddr = req.RequestContext.Identity.SourceIP

if req.MultiValueHeaders != nil {
for k, values := range req.MultiValueHeaders {
for _, value := range values {
Expand Down
4 changes: 3 additions & 1 deletion core/requestv2.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func (r *RequestAccessorV2) EventToRequest(req events.APIGatewayV2HTTPRequest) (

path := req.RawPath

//if RawPath empty is, populate from request context
// if RawPath empty is, populate from request context
if len(path) == 0 {
path = req.RequestContext.HTTP.Path
}
Expand Down Expand Up @@ -164,6 +164,8 @@ func (r *RequestAccessorV2) EventToRequest(req events.APIGatewayV2HTTPRequest) (
return nil, err
}

httpRequest.RemoteAddr = req.RequestContext.HTTP.SourceIP

for _, cookie := range req.Cookies {
httpRequest.Header.Add("Cookie", cookie)
}
Expand Down

0 comments on commit 2eab254

Please sign in to comment.