serverless / serverless/serverless

Feature Request: Allow multiple comma- or list-delimited method values per API Gateway event

Open
#9,782 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

cat/aws-event-api-gateway enhancement needs feedback
Dominant language
JavaScript
Stars
46.9k
Forks
5.7k
Avg merge
10h 7m
Merged PRs (30d)
57

Description

Q1: Description

Basically, I want to allow an API Gateway endpoint to tolerate exactly two HTTP verbs (GET and POST), but not ANY/"*" (it would appear the latter causes problems with CORS preflight OPTIONS, among other considerations).

It is certainly possible at the moment to do so by duplicating the - http: event as such:

functions:
  function1:
    handler: folder/function1.lambda_handler
    events:
      - http:
          path: /path
          method: GET
      - http:
          path: /path
          method: POST

But I have quite a few functions, and each has a relatively involved CORS setup, so doing so would mean 50+ lines of duplicated YAML.

Q2: Proposed solution

Ideally, I could do either:

    events:
      - http:
          path: /path
          method: GET, POST

or

    events:
      - http:
          path: /path
          method: 
            - GET
            - POST

I realize having the same endpoint accept both verbs - rather than splitting it to two endpoints - is a little weird, bordering on an anti-pattern. But that's where my business logic is taking it.

My env

Your Environment Information ---------------------------
Operating System: darwin
Node Version: 14.17.1
Framework Version: 2.52.1
Plugin Version: 5.4.3
SDK Version: 4.2.5
Components Version: 3.14.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no repository file or test. Start by tracing how Serverless Framework parses the http event's method and maps it to API Gateway routes, then compare the comma-delimited and list-valued forms. Done means either supported syntax accepts exactly GET and POST without duplicating the event, with coverage for the supported configuration.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, javascript
Domain
api, cloud
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.