Class: Adsf::Rack::CORS

Inherits:
Object
  • Object
show all
Defined in:
lib/adsf/rack/cors.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ CORS

Returns a new instance of CORS.



5
6
7
# File 'lib/adsf/rack/cors.rb', line 5

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/adsf/rack/cors.rb', line 9

def call(env)
  status, headers, body = *@app.call(env)

  new_headers =
    headers.merge(
      'Access-Control-Allow-Origin' => '*',
      'Access-Control-Allow-Headers' => 'Origin, X-Requested-With, Content-Type, Accept, Range',
    )

  [status, new_headers, body]
end