I am building an API in rails 4. Before invoking an action, I am trying first to check whether an attribute exist in the http header. Is there a way to do that instead of checking each in all actions of the controllers. The rails documentation mentions something like
constraints(lambda { |req| req.env["HTTP_CUSTOM_HEADER"] =~ /value/ }) do
#controller, action mapping
end
but I still want to give the user consuming my API a feedback. something like sending a json with a message stating: missing the custom attribute in the header