RackMotion provides a Rack-like interface for middleware that can intercept and alter HTTP requests and responses in RubyMotion. It's built on top of NSURLProtocol, which makes it, to borrow a line from Mattt Thompson, an Apple-sanctioned man-in-the-middle attack.
class EnableCORS def initialize(app) @app = app end def call(request) status, headers, data = @app.call(request) if request.allHTTPHeaderFields['Origin'] headers['Access-Control-Allow-Origin'] = request.allHTTPHeaderFields['Origin'] end return status, headers, data end end
And then, in your AppDelegate:
Add this line to your application's Gemfile:
And then execute:
Or install it yourself as:
$ gem install RackMotion