return 1;
}
+=item status_forbidden
+
+Returns a "403 FORBIDDEN" response. Takes a "message" argument
+as a scalar, which will become the value of "error" in the serialized
+response.
+
+Example:
+
+ $self->status_forbidden(
+ $c,
+ message => "access denied",
+ );
+
+=cut
+
+sub status_forbidden {
+ my $self = shift;
+ my $c = shift;
+ my %p = Params::Validate::validate( @_, { message => { type => SCALAR }, }, );
+
+ $c->response->status(403);
+ $c->log->debug( "Status Forbidden: " . $p{'message'} ) if $c->debug;
+ $self->_set_entity( $c, { error => $p{'message'} } );
+ return 1;
+}
+
=item status_not_found
Returns a "404 NOT FOUND" response. Takes a "message" argument
{ error => "Cannot do what you have asked!" },
"... status bad request message";
+ok $res = request( $t->get( url => '/rest/test_status_forbidden' ) );
+is $res->code, 403, '... status forbidden';
+is_deeply Load( $res->content ),
+ { error => "access denied" },
+ "... status forbidden";
+
ok $res = request( $t->get( url => '/rest/test_status_not_found' ) );
is $res->code, 404, '... status not found';
is_deeply Load( $res->content ),
message => "Cannot do what you have asked!", );
}
+sub test_status_forbidden : Local {
+ my ( $self, $c ) = @_;
+ $self->status_forbidden ( $c,
+ message => "access denied", );
+}
+
sub test_status_not_found : Local {
my ( $self, $c ) = @_;
$self->status_not_found( $c,