- 
                Notifications
    You must be signed in to change notification settings 
- Fork 9
Open
Description
I'd like to discuss adding the possibility to handle OPTIONS requests as well in the handler.
This would allow to handle CORS requests that initiate a Preflight request.
The handler could then act depending on the request method, as shown in the following example:
class Handler
  def run(body, headers)
    if headers['REQUEST_METHOD'] == 'OPTIONS'
      return [
        [],
        {
          'Allow' => 'POST, GET, OPTIONS',
          'Access-Control-Allow-Methods' => 'POST, GET, OPTIONS',
          'Access-Control-Allow-Origin' => '*',
          'Access-Control-Allow-Headers' => 'Accept'
        }
      ]
    end
    # ....
endThe change is backwards compatible, we'd only have to add one more route to sinatra.
We could also discuss to allow all available request methods.
Metadata
Metadata
Assignees
Labels
No labels