6

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?

cksk
  • 63
  • 1
  • 3

1 Answers1

4

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.

Jeremy Evans
  • 11,959
  • 27
  • 26
  • Oh wow, now I feel stupid for not trying that. Thanks, Jeremy! – cksk Apr 21 '16 at 13:47
  • @jeremy_evans does this mean that request.ip is `request.env['REMOTE_ADDR']`? Does request.ip also return proxied ip addresses found using `HTTP_X_FORWARDED_FOR`? Thanks! – Rachel Lanman Jan 08 '19 at 20:29
  • @jeremy_evans can somehow start to delegate and let the community help you with documentation. – Andrew Zhuk Aug 29 '20 at 22:00
  • @AndrewZhuk pull requests for Roda's documentation are always welcome. And request.ip comes from Rack, so the implementation will depend on the rack version in use. – Jeremy Evans Aug 31 '20 at 03:39