保存脚手架以供开发人员访问的最佳方法是什么?
我正在 Grails 2.0.RC1 中开发一个项目,我希望能够保存我的域对象的支架控制器和视图,使其成为“低级”,开发人员只能访问仍然修补的东西,同时能够开发视图和控制器的生产版本(具有相似的名称,尤其是控制器)。我想按原样保留它们,这样我就可以在更新域层时重新生成它们,所以仅仅移动它们很可能不起作用。
我希望有一种方法可以实现一些 UrlMapping 魔法,让我可以将“/mgr/book”的请求发送到脚手架的 Book 控制器,但“/book”将发送到我的生产控制器。我在文档中找不到有关如何为特定控制器组进行映射的任何内容(无需按名称与 $controller 符号指定每个控制器)。
我的另一个想法是将我的域层变成一个插件,然后创建一个仅用于脚手架视图的单独项目。在投入生产之前,这会更容易删除,但似乎也需要更多工作,并且引发了在同一个机器上同时运行两个 grails 应用程序的问题。
I'm working on a project in Grails 2.0.RC1 and I'd like to be able to save the scaffolded controllers and views for my domain objects to have as a "low-level", developer only access to still tinker with things while being able to develop the production version of the views and controllers (with similar names, especially for controllers). I'd like to preserve them as-is, so I can re-generate them as I make updates to the domain layer, so just moving them is most likely not going to work.
I'm hoping there's a way to do some UrlMapping magic that would let me have requests for "/mgr/book" go to the scaffolded Book controller, but "/book" would go to my production controller. I can't find anything in the docs about how to have mappings for specific groups of controllers (without specifying each controller by name versus a $controller notation).
My other thought is to turn my domain layer into a plug-in and then create a separate project that would be just for the scaffolded views. This would be easier to remove before going to production, but also seems like more work, and raises the issue of running two grails apps at the same time on the same box.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我会建议你按照你最后的想法去做。这也是我常用的方法:
这使您的主应用程序保持干净和简单,并且您仍然可以重新生成所有支架视图和视图。控制器如你所愿。而且至少 Eclipse STS 热部署仍然可以工作!
然而,目前还没有简单的解决方案可以按 URL 方式分离脚手架控制器。
I would advance you to go like your last idea. This is also my common approach:
This keeps your main-app clean and simple and you can still regenerate all your scaffolded views & controllers as you wish. And at least Eclipse STS hot-deployment will still work!
However there is no simple solution for seperating your scaffolded controllers URL-wise yet.
如果您使用 Spring Security,则应该能够使用 InterceptUrlMap 或 RequestMap 实例 以保护控制器 URL。
如果您的脚手架控制器仅用于脚手架(并且没有其他操作),那么您应该能够使用基本的 安全注释以保护整个控制器。
然后您可以像平常一样使用脚手架,并在登录后受到保护。
其他安全框架可以提供类似的访问控制。
If you are using Spring Security, you should be able to use an InterceptUrlMap or RequestMap Instances to secure the controller URLs.
If your scaffold controllers are only used for scaffolding (and don't have other actions), then you should be able to use basic Secured annotations to secure the entire controller.
Then you can use the scaffolding like normal, protected behind a login.
Other security frameworks may provide similar access control.