Added in Test Suite
Created Catalyst::Action::Serialize and Catalyst::Action::Deserialize
Added Data::Serializer actions
+ Added status_created helper method
use strict;
use warnings;
use base 'Catalyst::Controller';
+use Params::Validate qw(:all);
__PACKAGE__->mk_accessors(qw(serialize));
}
);
-sub begin : ActionClass('Deserialize') {
-}
+sub begin : ActionClass('Deserialize') {}
+
+sub end : ActionClass('Serialize') { }
+
+sub status_created {
+ my $self = shift;
+ my $c = shift;
+ my %p = validate(@_,
+ {
+ location => { type => SCALAR | OBJECT },
+ entity => { optional => 1 },
+ },
+ );
-sub end : ActionClass('Serialize') {
+ my $location;
+ if (ref($p{'location'})) {
+ $location = $p{'location'}->as_string;
+ }
+ $c->response->status(201);
+ $c->response->header('Location' => $location);
+ if (exists($p{'entity'})) {
+ $c->stash->{$self->config->{'serialize'}->{'stash_key'}} = $p{'entity'};
+ }
+ return 1;
}
1;