--- /dev/null
+* Override setup_classes from Catalyst::Base, so things that use
+ C::Controller:REST don't need to have ActionClass('REST') on them
+
+* Create generalized serializer/deserializer, that uses content_type to
+ choose
+
+* Document everything
+
+* More tests
+
--- /dev/null
+#
+# Catlyst::Action::Deserialize::YAML.pm
+# Created by: Adam Jacob, Marchex, <adam@marchex.com>
+# Created on: 10/12/2006 03:00:32 PM PDT
+#
+# $Id$
+
+package Catalyst::Action::Deserialize::YAML;
+
+use strict;
+use warnings;
+
+use base 'Catalyst::Action';
+use YAML::Syck;
+use Catalyst::Request::REST;
+
+sub execute {
+ my $self = shift;
+ my ( $controller, $c, $test ) = @_;
+
+ my $nreq = bless($c->request, 'Catalyst::Request::REST');
+ $c->request($nreq);
+ if ($c->request->method eq "POST" || $c->request->method eq "PUT") {
+ my $rdata = LoadFile($c->request->body);
+ $c->request->data($rdata);
+ $self->NEXT::execute( @_, );
+ } else {
+ $self->NEXT::execute( @_ );
+ }
+};
+
+1;
--- /dev/null
+#
+# REST.pm
+# Created by: Adam Jacob, Marchex, <adam@marchex.com>
+# Created on: 10/12/2006 03:00:32 PM PDT
+#
+# $Id$
+
+package Catalyst::Action::REST;
+
+use strict;
+use warnings;
+
+use base 'Catalyst::Action';
+
+sub dispatch {
+ my ( $self, $c ) = @_;
+
+ my $controller = $self->class;
+ my $method = $self->name . "_" . uc($c->request->method);
+ if ($controller->can($method)) {
+ $c->log->debug("REST ActionClass is calling $method");
+ return $controller->$method($c);
+ } else {
+ $c->log->debug("REST ActionClass is calling " . $self->name);
+ return $c->execute( $self->class, $self );
+ }
+}
+
+1;
--- /dev/null
+#
+# Catlyst::Action::Serialize::YAML.pm
+# Created by: Adam Jacob, Marchex, <adam@marchex.com>
+# Created on: 10/12/2006 03:00:32 PM PDT
+#
+# $Id$
+
+package Catalyst::Action::Serialize::YAML;
+
+use strict;
+use warnings;
+
+use base 'Catalyst::Action';
+use YAML::Syck;
+
+sub execute {
+ my $self = shift;
+ my ( $controller, $c, $test ) = @_;
+
+ my $stash_key = $controller->serialize->{'stash_key'} || 'rest';
+
+ if (! $c->response->content_type ) {
+ $c->response->content_type($c->req->content_type);
+ }
+ 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)$/;
+
+ $c->response->output( Dump( $c->stash->{$stash_key} ) );
+ return 1;
+};
+
+1;
--- /dev/null
+package Catalyst::Controller::REST;
+
+use strict;
+use warnings;
+use base 'Catalyst::Controller';
+
+__PACKAGE__->mk_accessors(qw(serialize));
+
+__PACKAGE__->config(
+ serialize => {
+ 'stash_key' => 'rest',
+ }
+);
+
+sub begin :ActionClass('Deserialize::YAML') {}
+
+sub end :ActionClass('Serialize::YAML') {}
+
+1;
--- /dev/null
+#
+# REST.pm
+# Created by: Adam Jacob, Marchex, <adam@marchex.com>
+# Created on: 10/13/2006 03:54:33 PM PDT
+#
+# $Id: $
+
+package Catalyst::Request::REST;
+
+use strict;
+use warnings;
+
+use base 'Catalyst::Request';
+
+__PACKAGE__->mk_accessors(qw(data));
+
+1;
+