Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get the remote ip (requester) on grape-api rails application

I have a working rails application with grape-gem working as an end point for some APIs in the application. I need to get the remote ip for the requester and return it back in the response. I could do that on regular controllers using

request.remote_ip

however, in grape calls, the 'request' is not a defined variable.

how can I get access to the remote ip on grape?

like image 667
alybadawy Avatar asked Dec 06 '13 03:12

alybadawy


1 Answers

Use env hash:

env['REMOTE_ADDR']
like image 57
NARKOZ Avatar answered Oct 17 '22 11:10

NARKOZ