【发布时间】:2016-09-07 02:02:42
【问题描述】:
我对使用 Google App 引擎和云平台的其他 Google 服务进行开发非常陌生,我想创建一个具有不同模块(因此它们可以有自己的生命周期)并使用端点的应用程序。
我在 api 路径上苦苦挣扎,因为我不知道如何将请求路由到好的模块。
我的目录树是这样的:
/myApp
/module1
__init__.py
main.py
/module2
__init__.py
main.py
module1.yaml
module2.yaml
dispatch.yaml
module1.yaml
application: myapp
runtime: python27
threadsafe: true
module: module1
version: 0
api_version: 1
handlers:
# The endpoints handler must be mapped to /_ah/spi.
# Apps send requests to /_ah/api, but the endpoints service handles mapping
# those requests to /_ah/spi.
- url: /_ah/spi/.*
script: module1.main.api
libraries:
- name: pycrypto
version: 2.6
- name: endpoints
version: 1.0
module2.yaml
application: myapp
runtime: python27
threadsafe: true
module: module2
version: 0
api_version: 1
handlers:
# The endpoints handler must be mapped to /_ah/spi.
# Apps send requests to /_ah/api, but the endpoints service handles mapping
# those requests to /_ah/spi.
- url: /_ah/spi/.*
script: module2.main.api
libraries:
- name: pycrypto
version: 2.6
- name: endpoints
version: 1.0
dispatch.yaml
dispatch:
- url: "*/_ah/spi/*"
module: module1
- url: "*/_ah/spi/.*"
module: module2
所以我希望在某处使用相应模块的名称('_ah/api/module1' 或'module1/_ah/api')来调用我的端点。我不知道在不同的 .yaml 文件中放什么。我什至不知道我在做什么是对的,还是可能的。
感谢您的回答。
【问题讨论】:
标签: python-2.7 google-app-engine google-cloud-endpoints