Original post

This post demonstrates how to get the IP address of incoming HTTP requests in . As a function, it attempts to use the X-FORWARDED-FOR header for code behind proxies and load balancers (such as on hosts like Heroku) while falling back to the RemoteAddr if the header isn’t found.
Just as an example, we created an echo server (of sorts) below to reply to incoming requests with the requesting ip address in json form.