AWS Lambda Python – 用于调用函数的 API 网关方法是哪一个?

huangapple go评论53阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2023年7月6日 21:08:20
  • 转载请务必保留本文链接:https://go.coder-hub.com/76629194.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定