【发布时间】:2016-09-08 01:38:12
【问题描述】:
感谢 asamarin,我已经能够弄清楚如何在同一个谷歌应用引擎中获取不同的端点(参见 Using Google endpoints in different modules of the same app)。
但我无法让它工作(至少对于开发服务器,我没有尝试将它推送到云端)。我有两个模块:module1 和 module2,它们每个都运行一个独立的 api(使用谷歌端点)。 在每个 moduleX/main.py 我都有这个代码:
import endpoints
from protorpc import remote
# ... some code
@endpoints.api(name="moduleX", version='v0') # X being 1 or 2 obviously
class ModuleX(remote.Service):
# ... definition of the different methods
api = endpoints.api_server([ModuleX])
当我使用两个对应的模块 yaml 文件运行 dev_appserver.py 时,它们启动良好(localhost:8080 上的 module1,localhost:8081 上的 module2)。
问题来了:
localhost:8080/_ah/api/explore 运行良好,我可以使用不同的方法查看我的 module1 API
localhost:8081/_ah/api/explore 需要很长时间才能找到与 module1 完全相同的 API,但当我单击它时,它找不到方法。
我和 Postman 玩了一会儿,看看木头下发生了什么,发现对 localhost:8080/_ah/api/discovery/v1/apis 和 localhost:8081/_ah... 的调用都返回与discoveryRestUrl 相同的信息是 localhost:8080/_ah/api/discovery/v1/apis/module1/v0/rest。你会承认这很有趣。
我做错了吗?是否只有开发服务器不处理具有多个服务的端点?
感谢您的帮助
【问题讨论】:
-
任何链接/git repo到使用多个服务端点的现有项目将不胜感激!
-
我面临同样的问题。找到任何解决方案了吗?
-
不,我们必须重新组织我们的项目:/
标签: python google-app-engine google-cloud-endpoints