$rc = $sclass->execute( $controller, $c );
}
if ( $rc eq "0" ) {
- return $self->_unsupported_media_type( $c, $content_type );
+ return $self->unsupported_media_type( $c, $content_type );
} elsif ( $rc ne "1" ) {
- return $self->_serialize_bad_request( $c, $content_type, $rc );
+ return $self->serialize_bad_request( $c, $content_type, $rc );
}
}
When you use this module, the request class will be changed to
L<Catalyst::Request::REST>.
+=head1 CUSTOM ERRORS
+
+For building custom error responses when de-serialization fails, you can create
+an ActionRole (and use L<Catalyst::Controller::ActionRole> to apply it to the
+C<begin> action) which overrides C<unsupported_media_type> and/or C<_serialize_bad_request>
+methods.
+
=head1 SEE ALSO
You likely want to look at L<Catalyst::Controller::REST>, which implements
}
};
if ($@) {
- return $self->_serialize_bad_request( $c, $content_type, $@ );
+ return $self->serialize_bad_request( $c, $content_type, $@ );
} elsif (!$rc) {
- return $self->_unsupported_media_type( $c, $content_type );
+ return $self->unsupported_media_type( $c, $content_type );
}
return 1;
well with others, or generally behave in a way that was very consistent
with the rest of Catalyst.
+=head1 CUSTOM ERRORS
+
+For building custom error responses when serialization fails, you can create
+an ActionRole (and use L<Catalyst::Controller::ActionRole> to apply it to the
+C<end> action) which overrides C<unsupported_media_type> and/or C<_serialize_bad_request>
+methods.
+
=head1 SEE ALSO
You likely want to look at L<Catalyst::Controller::REST>, which implements
# pick the best match that we have a serializer mapping for
my ($content_type) = grep { $map->{$_} } @accepted_types;
- return $self->_unsupported_media_type($c, $content_type)
+ return $self->unsupported_media_type($c, $content_type)
if not $content_type;
# carp about old text/x-json
$sclass .= $mc;
#}
if ( !grep( /^$sclass$/, @{ $self->_serialize_plugins } ) ) {
- return $self->_unsupported_media_type($c, $content_type);
+ return $self->unsupported_media_type($c, $content_type);
}
} else {
- return $self->_unsupported_media_type($c, $content_type);
+ return $self->unsupported_media_type($c, $content_type);
}
unless ( exists( $self->_loaded_plugins->{$sclass} ) ) {
my $load_class = $sclass;
if ($@) {
$c->log->error(
"Error loading $sclass for " . $content_type . ": $!" );
- return $self->_unsupported_media_type($c, $content_type);
+ return $self->unsupported_media_type($c, $content_type);
} else {
$self->_loaded_plugins->{$sclass} = 1;
}
return $sclass, $sarg, $content_type;
}
-sub _unsupported_media_type {
+sub unsupported_media_type {
my ( $self, $c, $content_type ) = @_;
$c->res->content_type('text/plain');
$c->res->status(415);
return undef;
}
-sub _serialize_bad_request {
+sub serialize_bad_request {
my ( $self, $c, $content_type, $error ) = @_;
$c->res->content_type('text/plain');
$c->res->status(400);