Class: Hyperdrive::Middleware::CORS
- Inherits:
-
Object
- Object
- Hyperdrive::Middleware::CORS
- Defined in:
- lib/hyperdrive/middleware/cors.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ CORS
constructor
A new instance of CORS.
Constructor Details
#initialize(app, options = {}) ⇒ CORS
Returns a new instance of CORS.
6 7 8 9 |
# File 'lib/hyperdrive/middleware/cors.rb', line 6 def initialize(app, = {}) @app = app @options = end |
Instance Method Details
#call(env) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/hyperdrive/middleware/cors.rb', line 11 def call(env) status, headers, body = @app.call(env) allowed_methods = '*' unless env['hyperdrive.resource'].nil? allowed_methods = env['hyperdrive.resource'].allowed_methods end cors = cors_headers(allowed_methods) headers.merge!(cors) [status, headers, body] end |