functions:
ptDevices:
name: ptDevices
handler: dist/devices/serverless.handler
timeout: 15
architecture: arm64
events:
- http:
method: any
path: /devices
- http:
method: any
path: /devices/connections
- http:
method: any
path: /devices/contexts
- http:
method: any
path: /devices/datetodate
如何在一个 Lambda fybctuib 中添加所有路径并分别获取每个触发器的准确端点路径?
当我运行这个时,我得到:
/devices
- any
/connections
- any
/contexts
- any
/datetodate
- any
但在 Lambda 函数中,所有触发器只有一个 (
Trigger:https://qw735635.execute-api.us-east-2.amazonaws.com/dev/devices/contexts
)
我想要什么:
/devices
- any (Trigger:https://qw735635.execute-api.us-east-2.amazonaws.com/dev/devices)
/connections
- any (Trigger:https://qw735635.execute-api.us-east-2.amazonaws.com/dev/devices/connections)
/contexts
- any (Trigger:https://qw735635.execute-api.us-east-2.amazonaws.com/dev/devices/contexts)
/datetodate
- any (Trigger:https://qw735635.execute-api.us-east-2.amazonaws.com/dev/devices/datetodate)
表示一个 Lambda 函数中的所有 4 个触发器。
您可以添加多个具有不同名称的函数,指向同一个 lambda 函数,每个函数都有不同的端点。
这是您可以执行此操作的代码:
functions:
ptDevices1:
name: ptDevices1
handler: dist/devices/serverless.handler
timeout: 15
architecture: arm64
events:
- httpApi:
path: /devices
method: any
ptDevices2:
name: ptDevices2
handler: dist/devices/serverless.handler
timeout: 15
architecture: arm64
events:
- httpApi:
path: /devices/connections
method: any
ptDevices3:
name: ptDevices3
handler: dist/devices/serverless.handler
timeout: 15
architecture: arm64
events:
- httpApi:
path: /devices/contexts
method: any
ptDevices4:
name: ptDevices4
handler: dist/devices/serverless.handler
timeout: 15
architecture: arm64
events:
- httpApi:
path: /devices/datetodate
method: any
通过这种方式,您将获得您在所需输出中提到的单独端点。