Skip to content

Instantly share code, notes, and snippets.

@amitosdev
Last active May 7, 2024 09:49
Show Gist options
  • Save amitosdev/fe2cba7d4e22e0de78382964105625c6 to your computer and use it in GitHub Desktop.
Save amitosdev/fe2cba7d4e22e0de78382964105625c6 to your computer and use it in GitHub Desktop.
Serverless HTTP Event

Serverless HTTP Event

There are 3 main types of Serverless HTTP events:

AWS Lambda Function URL

functions:
  hello:
    handler: handler.hello
    # Public by default
    url: true

The lambda doesn't support path on the deployment level, so you should do something like:

const { requestContext: { http: { method, path } }, body } = event
  if (method !== 'POST' || path !== '/foo') return { statusCode: 404 }

AWS REST API (API Gateway v1)

functions:
  hello:
    handler: handler.hello
    events:
      - http:
            method: GET
            path: /hello

AWS HTTP API (API Gateway v2)

functions:
  hello:
    handler: handler.hello
    events:
      - httpApi:
            method: GET
            path: /hello
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment