【发布时间】:2018-11-12 23:16:48
【问题描述】:
我正在阅读来自 Serverless 的这篇博文,内容是关于无服务器架构存在的不同模式。
我对@987654322@ 很感兴趣,我想试试看。
在我的serverless.yml 文件中使用此配置。
functions:
apps:
handler: handler.apps
events:
- http: post apps
cors: true
- http: patch users
- http: get users
cors: true
- http: delete users
以下输出来自运行serverless deploy。
POST - https://x7lpwa04.execute-api.us-west-2.amazonaws.com/staging/users
PATCH - https://x7lpwa04.execute-api.us-west-2.amazonaws.com/staging/users
GET - https://x7lpwa04.execute-api.us-west-2.amazonaws.com/staging/users
DELETE - https://x7lpwa04.execute-api.us-west-2.amazonaws.com/staging/users
现在在 CRUD 服务中,如果我想获取单个资源,我可能会为 get 端点 /staging/users/{id} 提供类似的东西。使用上述模式,是否由用户来传递像 /staging/users?id={id} 这样的查询字符串参数,而不是像 /staging/users/{id} 这样的路径参数?是否可以让端点有路径参数?
路径好像不能这样覆盖。
【问题讨论】:
标签: web serverless-framework serverless