serverless / serverless/serverless
Feature Request: Allow multiple comma- or list-delimited method values per API Gateway event
Nobody has claimed this yet.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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