package Catalyst::Controller::REST;
+use strict;
+use warnings;
-our $VERSION = '0.74';
+our $VERSION = '0.77';
+$VERSION = eval $VERSION;
=head1 NAME
Uses a regular Catalyst view. For example, if you wanted to have your
C<text/html> and C<text/xml> views rendered by TT:
- 'text/html' => [ 'View', 'TT' ],
- 'text/xml' => [ 'View', 'XML' ],
+ 'text/html' => [ 'View', 'TT' ],
+ 'text/xml' => [ 'View', 'XML' ],
Will do the trick nicely.
can ensure that something is always returned by setting the C<default>
config option:
- __PACKAGE__->config->{'default'} = 'text/x-yaml';
+ __PACKAGE__->config->{'default'} = 'text/x-yaml';
Would make it always fall back to the serializer plugin defined for text/x-yaml.
=cut
-use strict;
-use warnings;
use base 'Catalyst::Controller';
use Params::Validate qw(SCALAR OBJECT);
return 1;
}
+=item status_no_content
+
+Returns a "204 NO CONTENT" response.
+
+=cut
+
+sub status_no_content {
+ my $self = shift;
+ my $c = shift;
+ $c->response->status(204);
+ $self->_set_entity( $c, undef );
+ return 1.;
+}
+
=item status_bad_request
Returns a "400 BAD REQUEST" response. Takes a "message" argument
return 1;
}
+=item gone
+
+Returns a "41O GONE" response. Takes a "message" argument as a scalar,
+which will become the value of "error" in the serialized response.
+
+Example:
+
+ $self->status_gone(
+ $c,
+ message => "The document have been deleted by foo",
+ );
+
+=cut
+
+sub status_gone {
+ my $self = shift;
+ my $c = shift;
+ my %p = Params::Validate::validate( @_, { message => { type => SCALAR }, }, );
+
+ $c->response->status(410);
+ $c->log->debug( "Status Gone " . $p{'message'} ) if $c->debug;
+ $self->_set_entity( $c, { error => $p{'message'} } );
+ return 1;
+}
+
sub _set_entity {
my $self = shift;
my $c = shift;