+Thu 6 May 2010 09:27:56 - Release 0.84
+ Add a status_multiple_choices helper method to the Controller base class.
+
+ Allow 3XX responses to be serialized.
+
Mon 8 Feb 2010 22:17:12 GMT - Release 0.83
Make it possible to deserialize a request with a DELETE method. This probably
breaks 'strict' REST guidelines, but is useful for being able to delete multiple
use Module::Pluggable::Object;
use MRO::Compat;
-our $VERSION = '0.83';
+our $VERSION = '0.84';
$VERSION = eval $VERSION;
has plugins => ( is => 'rw' );
extends 'Catalyst::Action';
use Data::Serializer;
-our $VERSION = '0.83';
+our $VERSION = '0.84';
$VERSION = eval $VERSION;
sub execute {
extends 'Catalyst::Action';
use JSON qw( decode_json );
-our $VERSION = '0.83';
+our $VERSION = '0.84';
$VERSION = eval $VERSION;
sub execute {
extends 'Catalyst::Action';
-our $VERSION = '0.83';
+our $VERSION = '0.84';
$VERSION = eval $VERSION;
sub execute {
extends 'Catalyst::Action';
-our $VERSION = '0.83';
+our $VERSION = '0.84';
$VERSION = eval $VERSION;
sub execute {
extends 'Catalyst::Action';
use YAML::Syck;
-our $VERSION = '0.83';
+our $VERSION = '0.84';
$VERSION = eval $VERSION;
sub execute {
BEGIN { require 5.008001; }
-our $VERSION = '0.83';
+our $VERSION = '0.84';
$VERSION = eval $VERSION;
sub new {
use Module::Pluggable::Object;
use MRO::Compat;
-our $VERSION = '0.83';
+our $VERSION = '0.84';
$VERSION = eval $VERSION;
has _encoders => (
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)$/;
+ return 1 if $c->response->status =~ /^(?:204)$/;
my ( $sclass, $sarg, $content_type ) =
$self->_load_content_plugins( "Catalyst::Action::Serialize",
extends 'Catalyst::Action';
use Data::Serializer;
-our $VERSION = '0.83';
+our $VERSION = '0.84';
$VERSION = eval $VERSION;
sub execute {
extends 'Catalyst::Action';
use JSON ();
-our $VERSION = '0.83';
+our $VERSION = '0.84';
$VERSION = eval $VERSION;
has encoder => (
extends 'Catalyst::Action::Serialize::JSON';
use JSON::XS ();
-our $VERSION = '0.83';
+our $VERSION = '0.84';
$VERSION = eval $VERSION;
sub _build_encoder {
extends 'Catalyst::Action::Serialize::JSON';
-our $VERSION = '0.83';
+our $VERSION = '0.84';
$VERSION = eval $VERSION;
after 'execute' => sub {
extends 'Catalyst::Action';
-our $VERSION = '0.83';
+our $VERSION = '0.84';
$VERSION = eval $VERSION;
sub execute {
extends 'Catalyst::Action';
-our $VERSION = '0.83';
+our $VERSION = '0.84';
$VERSION = eval $VERSION;
sub execute {
extends 'Catalyst::Action';
use YAML::Syck;
-our $VERSION = '0.83';
+our $VERSION = '0.84';
$VERSION = eval $VERSION;
sub execute {
use YAML::Syck;
use URI::Find;
-our $VERSION = '0.83';
+our $VERSION = '0.84';
$VERSION = eval $VERSION;
sub execute {
use Catalyst::Request::REST;
use Catalyst::Utils ();
-our $VERSION = '0.83';
+our $VERSION = '0.84';
$VERSION = eval $VERSION;
after BUILDARGS => sub {
use Moose;
use namespace::autoclean;
-our $VERSION = '0.83';
+our $VERSION = '0.84';
$VERSION = eval $VERSION;
=head1 NAME
return 1.;
}
+=item status_multiple_choices
+
+Returns a "300 MULTIPLE CHOICES" response. Takes an "entity" to serialize, which should
+provide list of possible locations. Also takes optional "location" for preferred choice.
+
+=cut
+
+sub status_multiple_choices {
+ 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(300);
+ $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
extends 'Catalyst::Request';
with 'Catalyst::TraitFor::Request::REST';
-our $VERSION = '0.83';
+our $VERSION = '0.84';
$VERSION = eval $VERSION;
# Please don't take this as a recommended way to do things.
use namespace::autoclean;
-our $VERSION = '0.83';
+our $VERSION = '0.84';
$VERSION = eval $VERSION;
extends 'Catalyst::Request::REST';
use HTTP::Headers::Util qw(split_header_words);
use namespace::autoclean;
-our $VERSION = '0.83';
+our $VERSION = '0.84';
$VERSION = eval $VERSION;
has [qw/ data accept_only /] => ( is => 'rw' );
with 'Catalyst::TraitFor::Request::REST';
-our $VERSION = '0.83';
+our $VERSION = '0.84';
$VERSION = eval $VERSION;
has _determined_real_method => (
use strict;
use warnings;
-use Test::More tests => 18;
+use Test::More;
use YAML::Syck;
use FindBin;
is_deeply Load( $res->content ),
{ error => "Document have been deleted by foo" },
"... status gone message";
+
+ok $res = request( $t->get( url => '/rest/test_status_multiple_choices' ) );
+is $res->code, 300, "... multiple choices";
+is_deeply Load($res->content),
+ { choices => [qw(/rest/choice1 /rest/choice2)] },
+ "... 300 multiple choices has response body";
+
+done_testing;
+
);
}
+sub test_status_multiple_choices : Local {
+ my ( $self, $c ) = @_;
+ $self->status_multiple_choices(
+ $c,
+ location => '/rest/choice1',
+ entity => { choices => [qw(/rest/choice1 /rest/choice2)] }
+ );
+}
+
sub test_status_accepted : Local {
my ( $self, $c ) = @_;
$self->status_accepted( $c, entity => { status => "queued", } );