(Quick Reference)

responseFormats

Purpose

Statically defines the supported response formats used by the respond method.

Examples

class BookController {
    static responseFormats = ['xml', 'json']

def show(Long id) { respond Book.get(id) } }

Description

The responseFormats property is used to define the response formats supported by a controller and in turn used by the respond method. The respond method uses Content Negotiation to respond with the most appropriate content type. See the documentation on REST support for more information.