go - Golang Serverless 离线
问题描述
我是无服务器框架的新手,我有一些问题:我有一个在无服务器框架上开发的带有 Go Lang 的 APIGateway,我正在尝试让无服务器离线工作。我已经安装了 serverless-offline 插件,当我运行 sls offline start 命令时,一切都按预期进行。
当我在浏览器中运行“获取”路由时,出现以下错误:
我在 serverless.yml 中的函数配置
functions:
getOrders:
# The handler property points to the file and module containing the code you want to run in your function.
handler: cmd/api/getOrders
memorySize: 128 # Memory Size available to function while running
description: Get all orders and convert them.
events:
- http:
path: orders
method: get
我的处理程序:
func getAllOrders(ctx context.Context, request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
orders := services.GetAllOrders()
// Success HTTP response
body, _ := json.Marshal(&models.ListOrdersResponse{
Orders: orders,
})
return events.APIGatewayProxyResponse{
Body: string(body),
StatusCode: 200,
}, nil
}
func main() {
lambda.Start(getAllOrders)
}
我究竟做错了什么?
解决方案
推荐阅读
- audio - 如何在同一个 Alexa 意图函数中添加两个以上的音频(标签)文件?
- powershell - Foreach 循环在 powershell office365 中获取部门名称
- sql - 无法编写简单的插入查询 postgresql
- python - 如何从另一个文件夹读取数据文件而不在 python 中给出完整路径?
- typescript - 在 NGRX 选择器的上下文中,如何创建一个选择器,该选择器将返回一组对象,其中您为这些对象提供了一个 id 列表
- docker - Traefik 和我的世界
- html - Flexbox 增加 div 以占用剩余高度
- python - 如何自动进行项目ID编号?
- redux - 我们如何在 DvaJs 中创建一个 redux store?
- python-3.x - 基于多级条件在数据框中填充新列