codeconsole opened a new pull request, #16273:
URL: https://github.com/apache/grails-core/pull/16273

   An application whose controllers all follow the RESTful resource conventions 
has to declare a `resources` mapping per controller, or hand-write the eight 
equivalent method-prefixed mappings. The first grows the mapping table with the 
controller count; the second copies a framework convention into application 
code, where it drifts when the convention changes.
   
   Passing `*` as the `resources` argument applies the conventions to every 
controller:
   
   ```groovy
   "/$controller"(resources: '*')
   ```
   
   That generates the eight mappings once — not once per controller — and 
resolves the controller from the URL when a request is matched:
   
   ```groovy
   get    "/$controller(.$format)?"(action: 'index')
   post   "/$controller(.$format)?"(action: 'save')
   get    "/$controller/create"(action: 'create')
   get    "/$controller/$id/edit"(action: 'edit')
   get    "/$controller/$id(.$format)?"(action: 'show')
   put    "/$controller/$id(.$format)?"(action: 'update')
   patch  "/$controller/$id(.$format)?"(action: 'patch')
   delete "/$controller/$id(.$format)?"(action: 'delete')
   ```
   
   `includes`, `excludes` and `group` prefixes compose as they do for a named 
resource:
   
   ```groovy
   group "/api/v1", {
       "/$controller"(resources: '*', excludes: ['create', 'edit'])
   }
   ```
   
   The captured controller and action are validated as they are for any other 
wildcard mapping, so a URI that does not correspond to a registered controller 
and action does not match.
   
   Limitations, both rejected when the mappings are evaluated rather than left 
to produce mappings that cannot match:
   
   - the URL must capture the controller, so `"/books"(resources: '*')` is an 
error
   - child resources cannot be nested within the mapping, since the parent 
controller is not known until a request is matched


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to