Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to set value of RemoteAddr/RemoteIP by middleware #1008

Closed
lafriks opened this issue Apr 20, 2021 · 3 comments · Fixed by #1009
Closed

Add option to set value of RemoteAddr/RemoteIP by middleware #1008

lafriks opened this issue Apr 20, 2021 · 3 comments · Fixed by #1009

Comments

@lafriks
Copy link
Contributor

lafriks commented Apr 20, 2021

Maybe pointer to net.Addr could be added to RequestCtx set that it could be set by middleware that if set would be used by RequestCtx.RemoteAddr() instead of one from c.

This would allow implementing more robust and generic middlewares for handling X-Real-IP and/or X-Forwarded-For etc

@erikdubbelboer
Copy link
Collaborator

A pull request is welcome. I'm not sure if a pointer to a net.Addr or a method to set it would be better.

@lafriks
Copy link
Contributor Author

lafriks commented Apr 21, 2021

I can create a PR if idea is acceptable. I meant adding private variable to struct RequestCtx and adding method something like SetRemoteAddr that would set it.

@lafriks
Copy link
Contributor Author

lafriks commented Apr 21, 2021

@erikdubbelboer PR submitted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants