Method: Pliny::Middleware::CORS#call
- Defined in:
- lib/pliny/middleware/cors.rb
#call(env) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/pliny/middleware/cors.rb', line 21 def call(env) # preflight request: render a stub 200 with the CORS headers if cors_request?(env) && env["REQUEST_METHOD"] == "OPTIONS" [200, cors_headers(env), [""]] else status, headers, response = @app.call(env) # regular CORS request: append CORS headers to response if cors_request?(env) headers.merge!(cors_headers(env)) end [status, headers, response] end end |