return 1;
}
+=item status_found
+
+Returns a "302 FOUND" response. Takes an "entity" to serialize.
+Also takes optional "location" for preferred choice.
+
+=cut
+
+sub status_found {
+ my $self = shift;
+ my $c = shift;
+ my %p = Params::Validate::validate(
+ @_,
+ {
+ entity => 1,
+ location => { type => SCALAR | OBJECT, optional => 1 },
+ },
+ );
+
+ my $location;
+ if ( ref( $p{'location'} ) ) {
+ $location = $p{'location'}->as_string;
+ } else {
+ $location = $p{'location'};
+ }
+ $c->response->status(302);
+ $c->response->header( 'Location' => $location ) if exists $p{'location'};
+ $self->_set_entity( $c, $p{'entity'} );
+ return 1;
+}
+
=item status_bad_request
Returns a "400 BAD REQUEST" response. Takes a "message" argument
is $res->code, 204, "... status no content";
is $res->content, '', '... no content';
+ok $res = request( $t->get( url => '/rest/test_status_found' ) );
+is $res->code, 302, '... status found';
+is_deeply Load( $res->content ),
+ { status => 'found' },
+ "... status found message";
+
ok $res = request( $t->get( url => '/rest/test_status_bad_request' ) );
is $res->code, 400, '... status bad request';
is_deeply Load( $res->content ),
);
}
+sub test_status_found : Local {
+ my ( $self, $c ) = @_;
+ $self->status_found(
+ $c,
+ location => '/rest',
+ entity => { status => 'found' },
+ );
+}
+
sub test_status_accepted : Local {
my ( $self, $c ) = @_;
$self->status_accepted( $c, entity => { status => "queued", } );