【发布时间】:2014-06-09 14:45:41
【问题描述】:
[深入研究问题后,似乎问题不在于路由,而在于模块中端点的使用。新问题GAE Modules and Google Endpoints
我正在将 GAE 应用程序迁移到模块,但我对路由感到困惑,因为某些查询被正确路由,但不是全部。
我的根文件夹中有以下 dispatch.yaml。请注意,该 api 模块正在使用 Google Cloud Enpoints API
application: testapp
dispatch:
- url: "*/foo/*"
module: foomodule
- url: "*/_ah/spi/*"
module: api
- url: "testapp.appspot.com/"
module: default
然后按模块名称创建一个文件夹,每个文件夹都有一个 yaml 文件,使用处理程序定义 URL 模式,例如/www/www.yaml 作为我的默认模块
application: testapp
version: alpha
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /static
static_dir: static
- url: /.*
script: www.app
libraries:
- name: webapp2
version: latest
http://testapp.appspot.com/xxx 等查询被正确重定向到默认值,/foo/xxx 由 foomodule 处理,但 API 请求 (/_ah/spi/xxx) 将通过 404 转到默认模块。
但是,我可以在映射到 api 模块的实例的日志中看到 /_ah/spi/BackendService.logMessages 的 200 OK。 这个来自 alpha-dot-api-dot -testapp.appspot.com - 而 404 仅来自 testapp.appspot.com。 (注意:我想让我的查询从 testapp.appspot.com 工作)
我做错了什么吗?另外,有没有办法列出服务器上当前使用的配置以确保正确部署?
【问题讨论】:
-
你的 api yaml 文件中有
- url: /_ah/spi/处理程序吗? -
是的,我有处理程序:- url: /_ah/spi/.* 脚本:myapi.app
-
你跑了吗:
appcfg.py update dispatch.yaml www.yaml api.yaml foo.yaml?而且,在 api.yaml 中是否有module: api?您是否在 api 模块上运行了任何打开的实例?如果是这样,他们有过时的代码 - 杀死他们,然后再试一次。 -
@GAEfan - 是的,我在 api/api.yamp 中有模块引用。我已经运行 appcfg.py update www/www.yaml upload/upload.yaml api/api.yaml ; appcfg.py update_dispatch 。但仍然是同样的错误。即使在杀死实例之后。从 API 控制台/资源管理器调用 API 时也会出现 404。
标签: python google-app-engine dispatch