I have to built an angular js application as a client to consume the api. The problem is that the api doesn't support jsonp calls.
So I've created a rails application that makes the calls to the api and returns the content. I'm using the faraday gem
Right now I have a method for each call to the api. But since every method only creates a request, triggers the request and returns the content.
I'm was wandering if I can create a proxy controller that creates the request based on what it receives then creates an request with faraday and returns the result. Something like this :
def proxy_request
if request.method_symbol == :get || request.method_symbol == :delete
line 7: response = faraday_conn.run_request(request.method_symbol, request.fullpath, nil, request.headers)
elsif request.method_symbol == :post || request.method_symbol == :put || request.method_symbol == :patch
response = faraday_conn.run_request(request.method_symbol, request.fullpath, request.body.read, request.headers)
end
render :text => response.body, :status => response.status, :content_type => response.headers["Content-Type"]
end
This is not working. What I'm doing wrong ? It always fails with
NoMethodError (undefined method `strip' for #<StringIO:0x3436848>):
app/controllers/api_proxy_controller.rb:7:in `proxy_request'