my $self = shift;
my ( $controller, $c ) = @_;
- $self->NEXT::execute( @_ );
+ $self->NEXT::execute(@_);
return 1 if $c->req->method eq 'HEAD';
return 1 if length( $c->response->body );
return 1 if scalar @{ $c->error };
return 1 if $c->response->status =~ /^(?:204|3\d\d)$/;
- my ($sclass, $sarg, $content_type) = $self->_load_content_plugins("Catalyst::Action::Serialize", $controller, $c);
- return 1 unless defined $sclass;
+ my ( $sclass, $sarg, $content_type ) =
+ $self->_load_content_plugins( "Catalyst::Action::Serialize",
+ $controller, $c );
+ unless ( defined($sclass) ) {
+ if ( defined($content_type) ) {
+ $c->log->debug("Could not find a serializer for $content_type");
+ } else {
+ $c->log->debug(
+ "Could not find a serializer for an empty content type");
+ }
+ return 1;
+ }
+ $c->log->debug(
+ "Serializing with $sclass" . ( $sarg ? " [$sarg]" : '' ) );
my $rc;
if ( defined($sarg) ) {
} else {
$rc = $sclass->execute( $controller, $c );
}
- if ($rc eq 0) {
- return $self->_unsupported_media_type($c, $content_type);
- } elsif ($rc ne 1) {
- return $self->_serialize_bad_request($c, $content_type, $rc);
- }
+ if ( $rc eq 0 ) {
+ return $self->_unsupported_media_type( $c, $content_type );
+ } elsif ( $rc ne 1 ) {
+ return $self->_serialize_bad_request( $c, $content_type, $rc );
+ }
return 1;
}
__PACKAGE__->config(
serialize => {
- 'default' => 'YAML',
+ 'default' => 'text/x-yaml',
'stash_key' => 'rest',
'map' => {
+ 'text/html' => [ 'View', 'TT', ],
'text/x-yaml' => 'YAML',
'text/x-data-dumper' => [ 'Data::Serializer', 'Data::Dumper' ],
},
.. populate stash with data ..
}
+When you use this module, the request class will be changed to
+L<Catalyst::Request::REST>.
+
=head1 CONFIGURATION
=over 4
=item default
-The default Serialization format. See the next section for
-available options. This is used if a requested content-type
-is not recognized.
+The Content-Type of the default Serialization format. This must be a
+Content-Type associated with a plugin in the "map" section below.
+
+This is used if a requested content-type is not recognized.
=item stash_key
You may distribute this code under the same terms as Perl itself.
=cut
+