9.1.6.3 Using Named Configurations for Object Marshallers - Reference Documentation
Authors: Graeme Rocher, Peter Ledbrook, Marc Palmer, Jeff Brown, Luke Daley, Burt Beckwith, Lari Hotari
Version: 3.0.11
9.1.6.3 Using Named Configurations for Object Marshallers
It is also possible to register named configurations. For example:XML.createNamedConfig('publicApi') {
it.registerObjectMarshaller(Book) { Book book, XML xml ->
// do public API
}
}
XML.createNamedConfig('adminApi') {
it.registerObjectMarshaller(Book) { Book book, XML xml ->
// do admin API
}
}render or respond methods you can wrap the call in a named configuration if necessary to customize rendering per request:XML.use( isAdmin ? 'adminApi' : 'publicApi') {
render book as XML
}XML.use( isAdmin ? 'adminApi' : 'publicApi') {
respond book
}