Initial commit of Catalyst-Action-REST
[catagits/Catalyst-Action-REST.git] / lib / Catalyst / Action / Serialize / YAML.pm
CommitLineData
256c894f 1#
2# Catlyst::Action::Serialize::YAML.pm
3# Created by: Adam Jacob, Marchex, <adam@marchex.com>
4# Created on: 10/12/2006 03:00:32 PM PDT
5#
6# $Id$
7
8package Catalyst::Action::Serialize::YAML;
9
10use strict;
11use warnings;
12
13use base 'Catalyst::Action';
14use YAML::Syck;
15
16sub execute {
17 my $self = shift;
18 my ( $controller, $c, $test ) = @_;
19
20 my $stash_key = $controller->serialize->{'stash_key'} || 'rest';
21
22 if (! $c->response->content_type ) {
23 $c->response->content_type($c->req->content_type);
24 }
25 return 1 if $c->req->method eq 'HEAD';
26 return 1 if length( $c->response->body );
27 return 1 if scalar @{ $c->error };
28 return 1 if $c->response->status =~ /^(?:204|3\d\d)$/;
29
30 $c->response->output( Dump( $c->stash->{$stash_key} ) );
31 return 1;
32};
33
341;