aws / aws-lambda-go

Libraries, samples and tools to help Go developers develop AWS Lambda functions.
Apache License 2.0
3.58k stars 548 forks source link

lambdaurl: Populate RemoteAddr with SourceIP #546

Closed lyoung-confluent closed 5 months ago

lyoung-confluent commented 5 months ago

Currently when using the lamdbaurl package the RemoteAddr field of the parsed *http.Request is not populated:

// RemoteAddr allows HTTP servers and other software to record
// the network address that sent the request, usually for
// logging. This field is not filled in by ReadRequest and
// has no defined format. The HTTP server in this package
// sets RemoteAddr to an "IP:port" address before invoking a
// handler.
// This field is ignored by the HTTP client.
RemoteAddr string

This PR changes the behavior to populate the value from the underlying request context. This matches the behavior of other AWS libraries: https://github.com/awslabs/aws-lambda-go-api-proxy/blob/09c9b90f1fd1a45c05eb3a2a7a166526fcddabd8/core/requestv2.go#L168

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

codecov-commenter commented 5 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (cce0845) 72.93% compared to head (468b645) 72.95%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #546 +/- ## ========================================== + Coverage 72.93% 72.95% +0.01% ========================================== Files 26 26 Lines 1456 1457 +1 ========================================== + Hits 1062 1063 +1 Misses 322 322 Partials 72 72 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

bmoffatt commented 5 months ago

Nice, thanks!