Question

I would like to create a "Shell" of a Grails project that hosts functionality in plugins, with the URLs segregated by plugin name.

So the URLs for a Blog plugin used in the Shell project might look like: /shell/blog/viewBlogPost

But what I'm actually seeing is all of the plugins' controllers behave as if they are part of the shell project itself: /shell/viewBlogPost

Is there any way to declare that the Blog plugin's controllers be accessible only under a /blog path in the URL?

Was it helpful?

Solution

It seems like Grails plugins are not able to do this. The problem is that they lack encapsulation and composability, leading to artifact conflicts:

  • URL routing from plugins is simply merged together and cannot be nested
  • Controllers are not namespaced
  • Services are not namespaced

I opened an issue: GRAILS-9300

The Grails team has tentative plans to address this in 2.2, by using the plugin name as a namespace for artifacts.

OTHER TIPS

Yes, your plugins can register URL mappings just like the rest of your "shell" application can.

You can declare UrlMappings in a plugin by creating a file with a name ending in UrlMappings in your plugin (e.g. BlogPluginUrlMappings.groovy) and these will get merged into the main application's UrlMappings. You can setup mappings starting with /blog/ to route to your plugin's controllers.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top