How to get remote ip (requestor) to grape-api rails application

I have a rail application that is used as an endpoint for some of the APIs in the application. I need to get a remote ip for the requester and return it back in response. I could do this on regular controllers using

request.remote_ip 

however, in grape calls, β€œquery” is not a specific variable.

how can i access the remote ip on the grape?

+6
source share
1 answer

Use the env hash:

 env['REMOTE_ADDR'] 
+13
source

Source: https://habr.com/ru/post/959439/


All Articles