10.2 Mapping to REST resources

If you prefer to keep the declaration of the URL mapping in your UrlMappings.groovy file then simply removing the uri attribute of the Resource transformation and adding the following line to UrlMappings.groovy will suffice:

  1. "/books"(resources:"book")

Extending your API to include more end points then becomes trivial:

  1. "/books"(resources:"book") {
  2. "/publisher"(controller:"publisher", method:"GET")
  3. }

The above example will expose the URI /books/1/publisher.

A more detailed explanation on creating RESTful URL mappings can be found in the URL Mappings section of the user guide.