-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Add parameters to http event #2056
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add parameters to http event #2056
Conversation
|
I like the feature a lot, but I'd do it a bit differently, so instead of: We have This brings it in line with the request property and easily allow users to include standard variables through `${self:custom.querystrings}. Thoughts? |
|
@flomotlik I used a 1 on 1 mapping of AWS, perhaps it's even better to move them under - http:
path: posts/create
method: post
request:
parameters:
header:
foo: false
querystring:
url: true
foobar: false
path:
bar: false |
|
yup parameters makes sense. Only change I would do from your example is use plural for |
|
@svdgraaf as AWS have now released the new APIG implementation I think it makes sense to pick up this PR and implement/merge it. Let me know what the next steps are. |
|
I'll look into it on monday, update from master and check for other loose ends |
|
@flomotlik all good to go now 😄 The config is now plural as you requested: - http:
path: posts/create
method: post
request:
parameters:
headers:
foo: false
querystrings:
url: true
foobar: false
paths:
bar: false |
pmuens
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just reviewed it today. Great stuff. Works out of the box 👍
Good job @svdgraaf (as always).
GTM from my side ![]()
|
/cc @flomotlik |
|
@svdgraaf one quick question. How do I test the Here's the corresponding - http:
path: foo
method: GET
request:
parameters:
paths:
bar: true |
|
@pmuens I'm not sure actually, I only used the header and query parameters. I'll see if I can build an example (and document it). |
|
@svdgraaf thank you very much! That would be great! 👍 Other than that the parameter support works really well! Good job! |
|
Ok, I've put some time in it, and I know what the problem is. The issue is that path parameters are actually not supported via the RequestParameters, or at least, it's very badly documented. For the path parameters to work, you need to add the parameter to the path, like so: However, I see that there currently is an issue with this PR, as that when you make such an endpoint, it will not set any other RequestParameters that you have defined (eg: the headers/params). I have to find some time to find out why. |
|
@svdgraaf thanks for looking into it. Yes I was also struggling to find some resources on how to use path parameters. Great that you're about to tackle it. Let me know if you need any help there. 👍 |
|
Ok so we're waiting on this PR for now @svdgraaf correct? |
|
@flomotlik yeah, let's not merge it just yet until I have time to work on this, probably this weekend or Monday. |
pmuens
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Waiting on more investigation regarding the paths parameter usage
|
Ok, got it, the problem is just that it's badly documented. I added another paragraph in the documentation with a sample: 1b1ce33 If you define a function with a paths request parameter, it just has to be added to the method path as well, like so: # serverless.yml
functions:
create:
handler: posts.post_detail
events:
- http:
path: posts/{id}
method: get
integration: lambda
request:
parameters:
paths:
id: true
querystrings:
bar: trueWhich will end up in api gateway like so: btw: you could leave the |
|
something broke after the rebase with master, let me figure out why ;) |
|
@pmuens can you check again if this is now satisfactory? :) |
|
Cool stuff @svdgraaf 🌮 🎉 Thank you very much! |
|
I'm able to define a function as below and access the id path parameter in code using |
|
@jch254 Your comment to get Parameters should be in Docs. |

In order to test your functions in the AWS console, or to generate a proper SDK, you need to specify parameters for your functions. This PR adds that option, like so:
They will then show up in the console, swagger, SDK's, etc, for example:
