I am using RestClient in my ruby on rails app to send a get request to an api of my app like the following:
RestClient.get(url?params1=<val1>¶m2=<val2>..)
The problem is that I also have to pass the secret API key to access the api in header of the get request. I have no idea how to pass this parameter in header of the request and how to access this param api_key inside my controller to validate the request to get access to that api. So I want something like that:
class StudentsController < ApplicationController
before_filter :validate_access, :only => [:<api_name>]
private
def validate_access
.... < I don't have any idea what to write here>
In this restrict_access function I want to check the value of api_key in request header to determine whether the request will be given access to that function or not.