保存脚手架以供开发人员访问的最佳方法是什么?

发布于 2024-12-13 14:51:26 字数 423 浏览 3 评论 0原文

我正在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

鯉魚旗 2024-12-20 14:51:26

我会建议你按照你最后的想法去做。这也是我常用的方法:

  1. 为您的域模型和公共服务创建一个可嵌入的插件。这还包括常见的插件,例如 spring security 等。顺便说一句,这也将减少主应用程序的依赖解析时间。
  2. 为您的脚手架视图创建一个可嵌入的插件。更改支架控制器的模板以需要身份验证和管理组。
  3. 您的主应用程序使用这两个插件。

这使您的主应用程序保持干净和简单,并且您仍然可以重新生成所有支架视图和视图。控制器如你所愿。而且至少 Eclipse STS 热部署仍然可以工作!

然而,目前还没有简单的解决方案可以按 URL 方式分离脚手架控制器。

I would advance you to go like your last idea. This is also my common approach:

  1. Create an embeddable plugin for your domain model and common services. This also includes common plugins, like spring security and stuff. This will also reduce your dependency resolution time for the main-app btw.
  2. Create an embeddable plugin for your scaffolded views. Change the template of the scaffolded controllers to require authentication and admin-group.
  3. Your main-app uses both plugins.

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.

万人眼中万个我 2024-12-20 14:51:26

如果您使用 Spring Security,则应该能够使用 InterceptUrlMapRequestMap 实例 以保护控制器 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文