X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FController%2FREST.pm;h=2499e8379c1503996e1548a1b67effd6cdd52075;hb=178f8470708ff2ba9e1a761ceb3cd3c12ad9a778;hp=defe764410d5db0b664a8db3aeb951b2aed71299;hpb=8894935c030d66c4a113d3e28b7a9a1c58f8bf04;p=catagits%2FCatalyst-Action-Serialize-Data-Serializer.git diff --git a/lib/Catalyst/Controller/REST.pm b/lib/Catalyst/Controller/REST.pm index defe764..2499e83 100644 --- a/lib/Catalyst/Controller/REST.pm +++ b/lib/Catalyst/Controller/REST.pm @@ -234,6 +234,25 @@ Your views should have a C method like this: return $serialized; } +=item * Callback + +For infinite flexibility, you can provide a callback for the +deserialization/serialization steps. + + __PACKAGE__->config( + map => { + 'text/xml' => [ 'Callback', { deserialize => \&parse_xml, serialize => \&render_xml } ], + } + ); + +The C callback is passed a string that is the body of the +request and is expected to return a scalar value that results from +the deserialization. The C callback is passed the data +structure that needs to be serialized and must return a string suitable +for returning in the HTTP response. In addition to receiving the scalar +to act on, both callbacks are passed the controller object and the context +(i.e. C<$c>) as the second and third arguments. + =back By default, L will return a