首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >"Lambda函数的路由找不到“错误运行与SAM局部Golang函数?

"Lambda函数的路由找不到“错误运行与SAM局部Golang函数?
EN

Stack Overflow用户
提问于 2019-11-16 18:51:38
回答 1查看 542关注 0票数 0

我试图在Golang中编写一个Lambda函数(在我的MacBook上进行开发,同时运行Desktop ),遵循的快速启动。我执行以下步骤:

  1. 运行"sam -运行时go1.x -名称测试“以从模板生成函数。
  2. 运行"make“以获取依赖项。
  3. 运行"make“来构建生成到hello-world/hello-word的代码。
  4. 运行"sam local start-api“。

一切看上去都是正确的:

代码语言:javascript
复制
Mounting HelloWorldFunction at http://127.0.0.1:3000/hello [GET]
You can now browse to the above endpoints to invoke your functions. You do not need to restart/reload SAM CLI while working on your functions, changes will be reflected instantly/automatically. You only need to restart SAM CLI if you update your AWS SAM template
2019-11-16 10:39:19  * Running on http://127.0.0.1:3000/ (Press CTRL+C to quit)

但是当我卷曲端点时,我得到了502,我看到了一个错误:

代码语言:javascript
复制
2019-11-16 10:39:23 Exception on /hello [HEAD]
Traceback (most recent call last):
  File "/usr/local/Cellar/aws-sam-cli/0.31.0/libexec/lib/python3.7/site-packages/flask/app.py", line 2317, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/Cellar/aws-sam-cli/0.31.0/libexec/lib/python3.7/site-packages/flask/app.py", line 1840, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/Cellar/aws-sam-cli/0.31.0/libexec/lib/python3.7/site-packages/flask/app.py", line 1743, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/Cellar/aws-sam-cli/0.31.0/libexec/lib/python3.7/site-packages/flask/_compat.py", line 36, in reraise
    raise value
  File "/usr/local/Cellar/aws-sam-cli/0.31.0/libexec/lib/python3.7/site-packages/flask/app.py", line 1838, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/Cellar/aws-sam-cli/0.31.0/libexec/lib/python3.7/site-packages/flask/app.py", line 1824, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/local/Cellar/aws-sam-cli/0.31.0/libexec/lib/python3.7/site-packages/samcli/local/apigw/local_apigw_service.py", line 172, in _request_handler
    route = self._get_current_route(request)
  File "/usr/local/Cellar/aws-sam-cli/0.31.0/libexec/lib/python3.7/site-packages/samcli/local/apigw/local_apigw_service.py", line 236, in _get_current_route
    raise KeyError("Lambda function for the route not found")
KeyError: 'Lambda function for the route not found'
2019-11-16 10:39:23 127.0.0.1 - - [16/Nov/2019 10:39:23] "HEAD /hello HTTP/1.1" 502 -

我遗漏了什么?

EN

回答 1

Stack Overflow用户

发布于 2019-12-17 20:54:11

这次聚会晚了,你可能已经解决了。在没有看到任何代码的情况下,您似乎已经发出了HEAD请求,而不是GET请求,而且我怀疑您没有HEAD方法的路由,只有GET。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58894092

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档