X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FController%2FREST.pm;h=33eb25bcfce82b16492c124fa14cc111e824c5a7;hb=9cd203c9c0d7099ff38fb9e1132459d76d19a360;hp=2cd5f4777016139d5cec18450cb35649823d2281;hpb=95318468df4a065b0008603a98036fa76867bb22;p=catagits%2FCatalyst-Action-REST.git diff --git a/lib/Catalyst/Controller/REST.pm b/lib/Catalyst/Controller/REST.pm index 2cd5f47..33eb25b 100644 --- a/lib/Catalyst/Controller/REST.pm +++ b/lib/Catalyst/Controller/REST.pm @@ -83,6 +83,12 @@ Or if you use pre-Moose Catalyst versions, use parent 'Catalyst::Controller::REST'; +=head1 CONFIGURATION + +See L. Note that the C +key has been deprecated. + + =head1 SERIALIZATION Catalyst::Controller::REST will automatically serialize your @@ -174,12 +180,38 @@ you serialize be a HASHREF, we transform outgoing data to be in the form of: =item * L Uses a regular Catalyst view. For example, if you wanted to have your -C and C views rendered by TT: - - 'text/html' => [ 'View', 'TT' ], - 'text/xml' => [ 'View', 'XML' ], +C and C views rendered by TT, set: -Will do the trick nicely. + __PACKAGE__->config( + map => { + 'text/html' => [ 'View', 'TT' ], + 'text/xml' => [ 'View', 'XML' ], + } + ); + +Your views should have a C method like this: + + sub process { + my ( $self, $c, $stash_key ) = @_; + + my $output; + eval { + $output = $self->serialize( $c->stash->{$stash_key} ); + }; + return $@ if $@; + + $c->response->body( $output ); + return 1; # important + } + + sub serialize { + my ( $self, $data ) = @_; + + my $serialized = ... process $data here ... + + return $serialized; + } + =back