title: AWS Lambda: how to have multiple handlers for same path?
body: <p>I have a simple lambda function setup with a serverless.yml configuration. What I'm looking to do is to have an additional lambda function which would be called for OPTIONS method for any of the deployed lambda functions. For example, if /login is called with OPTIONS I want options handler to handle the execution. If /login is called with GET I want the actual login handler to handle the execution. Same for all the other handler functions as well.</p>
  <p><strong>Serverless.yml</strong></p>
  <pre class="lang-yaml prettyprint-override"><code>functions:
    login:
      handler: handler.login
      events:
        - http:
            path: login
            method: get
    stats:
      handler: handler.Stats
      events:
        - http:
            path: patientset/{id}/stats
            method: get
    options:
      handler: handler.options
      events:
        - http:
            path: '/' //Need something global like this
            method: options
  </code></pre>
  <p><strong>Handler.js</strong></p>
  <pre class="lang-js prettyprint-override"><code>module.exports.options = (event) =&gt; {
    const headers = setHeaders(event);  
    return {
      statusCode: 200,
      headers,
      body: JSON.stringify({})
    }
  }
  
  //Code updated in edit
    login:
      handler: handler.login
      events:
        - http:
            path: login
            method: get
            cors:
              origin: 'https://d2mo71maq8qx66.cloudfront.net'
              headers: ${self:custom.ALLOWED-HEADERS}
              allowCredentials: true
  </code></pre>