英文:
AWS Lambda Python - which API Gateway method is used to invoke the function
问题
我正在基于Python开发AWS Lambda函数。我有一个触发器 - API Gateway,其中包含2个方法 - Get和POST。
我感到很困惑,但我无法弄清楚如何捕获调用函数所使用的方法。我知道事件和上下文参数中不包含此信息,但我该从哪里获取这个信息?
英文:
I am working on AWS Lambda function based on Python. I have a trigger - API Gateway with 2 methods - Get and POST.
I feel so stupid, but i can't figure out how to capture which method was used to call the function. I know the event and context arguments don't contain this, but where can i get this info?
答案1
得分: 2
> 我知道事件和上下文参数不包含这个信息。
事件对象绝对包含这个信息。除非你在API Gateway中配置了自定义事件映射,否则事件对象将采用此处描述的格式。
你可以在事件的httpMethod
属性中看到HTTP方法。
英文:
> I know the event and context arguments don't contain this
The event object absolutely does contain this information. Unless you have configured custom event mapping in API Gateway, the event object will be in the format described here.
You can see the HTTP Method is in the httpMethod
property of the event.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论