Search code examples
rubyroda

How to get the client's IP address in Roda?


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?


Solution

  • 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.