将Cloud Endpoints API放入单独的App Engine模块中 [英] Putting a Cloud Endpoints API in a separate App Engine module
问题描述
我正在开发一个App Engine应用程序,并计划提供一个API。我想将这个API与主站点分开,所以我试图使用模块功能来分离这两个应用程序。主站点将是默认模块,API将位于api模块中。但是,我遇到了麻烦。
现在我的主应用程序的YAML文件如下所示:
应用程序:my-app
模块:默认
运行时:python27
api_version:1
...
处理程序:
#根处理程序
- url:/.*
脚本:main.app
安全:总是
.. 。
和API模块YAML文件一样:
应用程序:my-app
模块:api
运行时:python27
api_version:1
处理程序:
#端点处理程序
- url:/_ah/spi/.*
脚本:api_main.app
安全:总是
...
在开发服务器上,应用程序在端口8000上提供,而API在端口7998上提供。
使用此配置,我的API不起作用。每当我尝试使用localhost:7998 / _ah / api / explorer访问它时,我都没有得到任何结果。如果我尝试手动运行API请求,会出现以下错误: {error:{message:BackendService.getApiConfigs Error}}
p>
奇怪的是我在开发服务器日志中也看到以下几行:
INFO 2014-06-15 18:00:00 32,368 module.py:639] default:POST /_ah/spi/BackendService.getApiConfigs HTTP / 1.1500 -
INFO 2014-06-15 18 :00:32,368 module.py:639] api:GET / _ah / api / my-app / v1 / events HTTP / 1.1500 60
好像API模块正在尝试将数据发送到默认模块(如日志的第一行所示)。
<现在,我发现唯一的解决方法是在默认的YAML文件中为
/ _ ah / spi /.*
添加相同的处理程序,但在这种情况下,主应用程序和API无效。 有人可以告诉我,我试图实现的配置是否受Cloud Endpoints支持?
非常感谢!
同样的问题,我能够在可能做出决定之后继续工作:我发现的(唯一)云端模块是默认模块。然后我在开发服务器上侦听不同端口的两个模块,可以在日志和xxx.appspot.com上看到prot数字:yourprojectid.appspot.com用于云端点和modulename-dot-yourprojectid.appspot。 com为其他模块
I am developing an App Engine app and plan to also provide an API. I would like to separate this API from the main site, so I'm trying to use the "modules" feature to separate both apps. The main site would be the "default" module, and the API would lie in the "api" module. However, I'm having troubles with this.
Right now my main app's YAML file is like this:
application: my-app
module: default
runtime: python27
api_version: 1
...
handlers:
# Root handler
- url: /.*
script: main.app
secure: always
...
And the API module YAML file, like this:
application: my-app
module: api
runtime: python27
api_version: 1
handlers:
# Endpoints handler
- url: /_ah/spi/.*
script: api_main.app
secure: always
...
On the development server, the app is served on port 8000, and the API on port 7998.
With this configuration, my API doesn't work. Whenever I try to access it using localhost:7998/_ah/api/explorer, I don't get any result. If I try to run an API request manually, I get the following error: {"error": {"message": "BackendService.getApiConfigs Error"}}
.
What's strange is I'm also seeing the following lines in the development server logs:
INFO 2014-06-15 18:00:32,368 module.py:639] default: "POST /_ah/spi/BackendService.getApiConfigs HTTP/1.1" 500 -
INFO 2014-06-15 18:00:32,368 module.py:639] api: "GET /_ah/api/my-app/v1/events HTTP/1.1" 500 60
It seems like the API module is trying to POST data to the default module (as seen in the first line of logs).
Right now, the only workaround I found is to add the same handlers for /_ah/spi/.*
in the default YAML file, but in this situation the separation between the main app and the API is not effective.
Can someone tell me if the configuration I'm trying to achieve is supported by Cloud Endpoints? Thank you very much!
Same problem, I was able to make it work after may temptatives: the (only) way i found is to make the cloud endopoints module the default module. Then i have: on the dev server the two modules listening at different ports, you can see prot numbers on the log and on xxx.appspot.com: yourprojectid.appspot.com for the cloud endpoints and modulename-dot-yourprojectid.appspot.com for the other module
这篇关于将Cloud Endpoints API放入单独的App Engine模块中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!