slattery
slattery

Reputation: 1379

How to nest plugin URLs?

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?

Upvotes: 1

Views: 181

Answers (3)

slattery
slattery

Reputation: 1379

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.

Upvotes: 1

Ken Liu
Ken Liu

Reputation: 22914

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.

Upvotes: 0

cdeszaq
cdeszaq

Reputation: 31280

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

Upvotes: 0

Related Questions