I'm using Roda, and I need to get the client's IP address from the http request. In Sinatra, I think this would be:
request.ip
Is there an equivalent method in Roda?
After the client establishes a successful connection to the server, the IP address of the client will be printed on the server console.
The easiest way to find your IP address in Node. js is to pull the client IP address from the incoming HTTP request object. If you are running Express in your Node app, this is very easy to do. Access the socket field of the Express request object, and then look up the remoteAddress property of that field.
That exact code should work in Roda. It's not mentioned explicitly in Roda's documentation, but Roda::RodaRequest is a subclass of Rack::Request, and Rack::Request#ip returns the client's IP.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With