2

Our Grails 2.5 web application has REST API.

We need to start a new version of the API so a group was created in UrlMappings.groovy like this:

group ("/v2") {

   "/documents"(resources: 'document') {
     "/meta"(resource: 'documentInfo', includes: ['show', 'update']) 
   }

   "/folders"(resources: 'folder')

   apiVersion = 2
}

The thing is that parameter apiVersion is not defined in params in controller actions.

The parameter is properly set if it is defined in each of the resources like this:

group ("/v2") {

   "/documents"(resources: 'document') {
     "/meta"(resource: 'documentInfo', includes: ['show', 'update']) {
       apiVersion = 2
     }
     apiVersion = 2
   }

   "/folders"(resources: 'folder') {
     apiVersion = 2
   }

}

How can I properly define a parameter on the group level?

matejk
  • 798
  • 1
  • 14
  • 27

1 Answers1

0

Workaround will be using namespace... although my attempt to define it at group level wont work but you can give a try. But defining at resource level works even for nested resources.

group ("/v2") {

   "/documents"(resources: 'document', namespace:'v2') {
     "/meta"(resource: 'documentInfo', includes: ['show', 'update']) 
   }

   "/folders"(resources: 'folder', , namespace:'v2')
}
Satish
  • 61
  • 4