英文:
Map App Engine Modules (former Backends) to separate Go program
问题
我们正在使用App Engine和Go语言。
最近,Google弃用了Backends,转而使用Modules。现在,除了Python或PHP之外,对于App Engine中的Go语言,你不需要将URI映射到脚本。相反,在app.yaml中使用伪脚本_go_app,并通过你实现的路由机制将URI路由到处理程序。重点是,路由是在编译后的Go程序内部发生的。
我想知道,这对于Modules意味着什么。
是否有办法将Modules映射到不同的Go程序?我希望保持代码的分离。
不幸的是,Google的文档并没有提供太多帮助:https://developers.google.com/appengine/docs/go/modules/.
英文:
We are using App Engine and Go.
Google recently deprecated Backends in favor of Modules. Now, other than with Python or PHP, with Go for App Engine, you don't map URIs to Scripts. Instead, the pseudo script _go_app is used in app.yaml and URIs are routed to handlers by whatever routing mechanism you implement. The point is, the routing happens from within the compiled Go program.
I wonder, what this means for Modules.
Is there any way of mapping Modules to different Go programs? I'd love to keep the code separate.
Google's docs unfortunately or not of much help: https://developers.google.com/appengine/docs/go/modules/.
答案1
得分: 1
是的,每个模块都可以是一个完全独立的代码库。你甚至可以让每个模块使用不同的编程语言。当然,每个模块都可以访问相同的数据存储。
你需要确保正确设置调度程序,以将请求映射到正确的模块。
通过调度程序路由的请求会通过goapp注册的URL进行路由。如果不使用调度程序,你将无法将一个go模块的请求路由到另一个go模块中,因为所有请求默认都会路由到主模块。
你可以在这里阅读更多关于在模块之间路由请求的信息:https://developers.google.com/appengine/docs/go/modules/routing
英文:
Yes - each module can be an entire separate codebase. You can even have each module use a different language. Each module will be able to access the same datastore of course.
You need to make sure to setup your dispatch correctly to map requests to the correct module.
The requests routed via the dispatch are then routed via the goapp registered urls. You will not be able to route requests from one go module to another inside of your default module without using the dispatch because all requests default to the main module.
You can read more about routing requests between modules here: https://developers.google.com/appengine/docs/go/modules/routing
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论