+++ /dev/null
-# Version control files and dirs.
-\bRCS\b
-\bCVS\b
-,v$
-\B\.svn\b
-\B\.git(ignore)?\b
-
-# Makemaker generated files and dirs.
-^MANIFEST\.
-^Makefile$
-^MYMETA\.
-^blib/
-^MakeMaker-\d
-^pm_to_blib$
-^Catalyst-Action-REST-
-# Temp, old and emacs backup files.
-~$
-\.old$
-^#.*#$
-^\.#
-\.shipit
repository 'git://git.shadowcat.co.uk/catagits/Catalyst-Action-REST.git';
-add_metadata( x_authority => 'cpan:BOBTFISH' );
-
WriteAll;
-
+++ /dev/null
-NAME
- Catalyst::Action::REST - Automated REST Method Dispatching
-
-SYNOPSIS
- sub foo :Local :ActionClass('REST') {
- ... do setup for HTTP method specific handlers ...
- }
-
- sub foo_GET {
- ... do something for GET requests ...
- }
-
- # alternatively use an Action
- sub foo_PUT : Action {
- ... do something for PUT requests ...
- }
-
-DESCRIPTION
- This Action handles doing automatic method dispatching for REST
- requests. It takes a normal Catalyst action, and changes the dispatch to
- append an underscore and method name. First it will try dispatching to
- an action with the generated name, and failing that it will try to
- dispatch to a regular method.
-
- For example, in the synopsis above, calling GET on "/foo" would result
- in the foo_GET method being dispatched.
-
- If a method is requested that is not implemented, this action will
- return a status 405 (Method Not Found). It will populate the "Allow"
- header with the list of implemented request methods. You can override
- this behavior by implementing a custom 405 handler like so:
-
- sub foo_not_implemented {
- ... handle not implemented methods ...
- }
-
- If you do not provide an _OPTIONS subroutine, we will automatically
- respond with a 200 OK. The "Allow" header will be populated with the
- list of implemented request methods.
-
- It is likely that you really want to look at Catalyst::Controller::REST,
- which brings this class together with automatic Serialization of
- requests and responses.
-
- When you use this module, it adds the Catalyst::TraitFor::Request::REST
- role to your request class.
-
-METHODS
- dispatch
- This method overrides the default dispatch mechanism to the
- re-dispatching mechanism described above.
-
-SEE ALSO
- You likely want to look at Catalyst::Controller::REST, which implements
- a sensible set of defaults for a controller doing REST.
-
- This class automatically adds the Catalyst::TraitFor::Request::REST role
- to your request class. If you're writing a web application which
- provides RESTful responses and still needs to accommodate web browsers,
- you may prefer to use Catalyst::TraitFor::Request::REST::ForBrowsers
- instead.
-
- Catalyst::Action::Serialize, Catalyst::Action::Deserialize
-
-TROUBLESHOOTING
- Q: I'm getting a "415 Unsupported Media Type" error. What gives?!
- A: Most likely, you haven't set Content-type equal to
- "application/json", or one of the accepted return formats. You can
- do this by setting it in your query accepted return formats. You can
- do this by setting it in your query string thusly:
- "?content-type=application%2Fjson (where %2F == / uri escaped)."
-
- NOTE Apache will refuse %2F unless configured otherwise. Make sure
- "AllowEncodedSlashes On" is in your httpd.conf file in order for
- this to run smoothly.
-
-AUTHOR
- Adam Jacob <adam@stalecoffee.org>, with lots of help from mst and
- jrockway
-
- Marchex, Inc. paid me while I developed this module.
- (<http://www.marchex.com>)
-
-CONTRIBUTORS
- Tomas Doran (t0m) <bobtfish@bobtfish.net>
-
- John Goulah
-
- Christopher Laco
-
- Daisuke Maki <daisuke@endeworks.jp>
-
- Hans Dieter Pearcey
-
- Brian Phillips <bphillips@cpan.org>
-
- Dave Rolsky <autarch@urth.org>
-
- Luke Saunders
-
- Arthur Axel "fREW" Schmidt <frioux@gmail.com>
-
- J. Shirley <jshirley@gmail.com>
-
-COPYRIGHT
- Copyright (c) 2006-2011 the above named AUTHOR and CONTRIBUTORS
-
-LICENSE
- You may distribute this code under the same terms as Perl itself.
-
--- /dev/null
+name = Catalyst-Action-REST
+version = 0.93
+author = Adam Jacob <adam@stalecoffee.org>
+license = Perl_5
+copyright_holder = Adam Jacob
+
+[GatherDir]
+[MetaJSON]
+
+; There's not good Module::Install support for our optional dependencies...
+; FakeFaker will just use our previously created Makefile.PL for now
+[FakeFaker]
+[Manifest]
+[ManifestSkip]
+[PruneCruft]
+[License]
+[Readme]
+[PkgVersion]
+[Repository]
+web = http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits/Catalyst-Action-REST.git;a=summary
+[Authority]
+
+[@Git]
+
+[ExtraTests]
+[PodSyntaxTests]
+[Test::PodSpelling]
+stopwords = Wiki
+stopwords = json
+stopwords = APIs
+stopwords = ActionClass
+stopwords = Daisuke
+stopwords = Daisuke
+stopwords = Deserialize
+stopwords = Deserializer
+stopwords = Deserializing
+stopwords = Doran
+stopwords = Goulah
+stopwords = JSON
+stopwords = Laco
+stopwords = Maki
+stopwords = Maki
+stopwords = Marchex
+stopwords = Multipart
+stopwords = Pearcey
+stopwords = Rolsky
+stopwords = RESTful
+stopwords = RESTful
+stopwords = SERIALIZERS
+stopwords = TT
+stopwords = Wikipedia
+stopwords = XHR
+stopwords = XMLHttpRequest
+stopwords = YAML
+stopwords = conf
+stopwords = deserialization
+stopwords = deserialize
+stopwords = deserialized
+stopwords = deserializing
+stopwords = fREW
+stopwords = html
+stopwords = http
+stopwords = javascript
+stopwords = jrockway
+stopwords = mst
+stopwords = multipart
+stopwords = namespace
+stopwords = plugins
+stopwords = request's
+stopwords = serializer
+stopwords = thusly
+stopwords = wildcard
+
+; Since we're using FakeFaker, these dependencies need to be added to the Makefile.PL as well
+[Prereqs]
+perl = 5.8.1
+Moose = 1.03
+namespace::autoclean = 0
+Catalyst::Runtime = 5.80030
+Params::Validate = 0.76
+YAML::Syck = 0.67
+Module::Pluggable::Object = 0
+LWP::UserAgent = 2.033
+Data::Serializer = 0.36
+Class::Inspector = 1.13
+URI::Find = 0
+MRO::Compat = 0.10
+
+; Since we're using FakeFaker, these dependencies need to be added to the Makefile.PL as well
+[Prereqs / RuntimeSuggests]
+JSON = 2.12
+JSON::XS = 2.2222
+Data::Taxi = 0
+Config::General = 0
+PHP::Serialization = 0
+FreezeThaw = 0
+XML::Simple = 0
+
+[Prereqs / TestRequires]
+Test::More = 0.88
+
+[Prereqs / AuthorRequires]
+Test::Pod = 1.14
+Module::Info = 0
+File::Find::Rule = 0
+JSON = 2.12
+JSON::XS = 2.2222
+Data::Taxi = 0
+Config::General = 0
+PHP::Serialization = 0
+FreezeThaw = 0
+XML::Simple = 0
use MRO::Compat;
use Moose::Util::TypeConstraints;
-our $VERSION = '0.93';
-$VERSION = eval $VERSION;
-
has plugins => ( is => 'rw' );
has deserialize_http_methods => (
extends 'Catalyst::Action';
-our $VERSION = '0.93';
-$VERSION = eval $VERSION;
-
sub execute {
my $self = shift;
my ( $controller, $c, $callbacks ) = @_;
my $compartment = Safe->new;
$compartment->permit_only( qw(padany null lineseq const pushmark list anonhash anonlist refgen leaveeval undef) );
-our $VERSION = '0.93';
-$VERSION = eval $VERSION;
-
sub execute {
my $self = shift;
my ( $controller, $c, $serializer ) = @_;
extends 'Catalyst::Action';
use JSON;
-our $VERSION = '0.93';
-$VERSION = eval $VERSION;
-
sub execute {
my $self = shift;
my ( $controller, $c, $test ) = @_;
extends 'Catalyst::Action';
-our $VERSION = '0.93';
-$VERSION = eval $VERSION;
-
sub execute {
return 1;
}
extends 'Catalyst::Action';
-our $VERSION = '0.93';
-$VERSION = eval $VERSION;
-
sub execute {
my $self = shift;
my ( $controller, $c, $test ) = @_;
extends 'Catalyst::Action';
use YAML::Syck;
-our $VERSION = '0.93';
-$VERSION = eval $VERSION;
-
sub execute {
my $self = shift;
my ( $controller, $c, $test ) = @_;
extends 'Catalyst::Action::Deserialize';
use HTTP::Body;
-our $VERSION = '0.93';
-$VERSION = eval $VERSION;
-
our $NO_HTTP_BODY_TYPES_INITIALIZATION;
$HTTP::Body::TYPES->{'multipart/mixed'} = 'HTTP::Body::MultiPart' unless $NO_HTTP_BODY_TYPES_INITIALIZATION;
BEGIN { require 5.008001; }
-our $VERSION = '0.93';
-$VERSION = eval $VERSION;
-
sub BUILDARGS {
my $class = shift;
my $config = shift;
use Moose;
use namespace::autoclean;
-our $VERSION = '0.93';
-$VERSION = eval $VERSION;
-
extends 'Catalyst::Action::REST';
use Catalyst::Request::REST::ForBrowsers;
use Module::Pluggable::Object;
use MRO::Compat;
-our $VERSION = '0.93';
-$VERSION = eval $VERSION;
-
has _encoders => (
is => 'ro',
isa => 'HashRef',
extends 'Catalyst::Action';
-our $VERSION = '0.93';
-$VERSION = eval $VERSION;
-
sub execute {
my $self = shift;
my ( $controller, $c, $callbacks ) = @_;
extends 'Catalyst::Action';
use Data::Serializer;
-our $VERSION = '0.93';
-$VERSION = eval $VERSION;
-
sub execute {
my $self = shift;
my ( $controller, $c, $serializer ) = @_;
extends 'Catalyst::Action';
use JSON ();
-our $VERSION = '0.93';
-$VERSION = eval $VERSION;
-
has encoder => (
is => 'ro',
lazy_build => 1,
extends 'Catalyst::Action::Serialize::JSON';
use JSON::XS ();
-our $VERSION = '0.93';
-$VERSION = eval $VERSION;
-
sub _build_encoder {
my $self = shift;
return JSON::XS->new->convert_blessed;
extends 'Catalyst::Action::Serialize::JSON';
-our $VERSION = '0.93';
-$VERSION = eval $VERSION;
-
after 'execute' => sub {
my $self = shift;
my ($controller, $c) = @_;
extends 'Catalyst::Action';
-our $VERSION = '0.93';
-$VERSION = eval $VERSION;
-
sub execute {
my $self = shift;
my ( $controller, $c, $view ) = @_;
extends 'Catalyst::Action';
-our $VERSION = '0.93';
-$VERSION = eval $VERSION;
-
sub execute {
my $self = shift;
my ( $controller, $c ) = @_;
extends 'Catalyst::Action';
use YAML::Syck;
-our $VERSION = '0.93';
-$VERSION = eval $VERSION;
-
sub execute {
my $self = shift;
my ( $controller, $c ) = @_;
use YAML::Syck;
use URI::Find;
-our $VERSION = '0.93';
-$VERSION = eval $VERSION;
-
sub execute {
my $self = shift;
my ( $controller, $c ) = @_;
use Catalyst::Request::REST;
use Catalyst::Utils ();
-our $VERSION = '0.93';
-$VERSION = eval $VERSION;
-
after BUILDARGS => sub {
my $class = shift;
my $config = shift;
use Moose;
use namespace::autoclean;
-our $VERSION = '0.93';
-$VERSION = eval $VERSION;
-
=head1 NAME
Catalyst::Controller::REST - A RESTful controller
return 1;
}
+=item status_moved
+
+Returns a "301 MOVED" response. Takes an "entity" to serialize,
+and a "location" where the created object can be found.
+
+Example:
+
+ $self->status_moved(
+ $c,
+ location => '/somewhere/else',
+ entity => {
+ radiohead => "Is a good band!",
+ }
+ );
+
+=cut
+
+sub status_moved {
+ my $self = shift;
+ my $c = shift;
+ my %p = Params::Validate::validate(
+ @_,
+ {
+ location => { type => SCALAR | OBJECT },
+ entity => { optional => 1 },
+ },
+ );
+
+ my $location;
+ if ( ref( $p{'location'} ) ) {
+ $location = $p{'location'}->as_string;
+ } else {
+ $location = $p{'location'};
+ }
+ $c->response->status(301);
+ $c->response->header( 'Location' => $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.93';
-$VERSION = eval $VERSION;
-
# Please don't take this as a recommended way to do things.
# The code below is grotty, badly factored and mostly here for back
# compat..
use namespace::autoclean;
-our $VERSION = '0.93';
-$VERSION = eval $VERSION;
-
extends 'Catalyst::Request::REST';
with 'Catalyst::TraitFor::Request::REST::ForBrowsers';
use HTTP::Headers::Util qw(split_header_words);
use namespace::autoclean;
-our $VERSION = '0.93';
-$VERSION = eval $VERSION;
-
has [qw/ data accept_only /] => ( is => 'rw' );
has accepted_content_types => (
with 'Catalyst::TraitFor::Request::REST';
-our $VERSION = '0.93';
-$VERSION = eval $VERSION;
-
has _determined_real_method => (
is => 'rw',
isa => 'Bool',
+++ /dev/null
-use strict;
-use warnings;
-
-use Test::More;
-
-eval "use Test::Spelling";
-plan skip_all => "Test::Spelling required for testing POD coverage"
- if $@;
-
-my @stopwords;
-for (<DATA>) {
- chomp;
- push @stopwords, $_
- unless /\A (?: \# | \s* \z)/msx; # skip comments, whitespace
-}
-
-add_stopwords(@stopwords);
-set_spell_cmd('aspell list -l en');
-
-# This prevents a weird segfault from the aspell command - see
-# https://bugs.launchpad.net/ubuntu/+source/aspell/+bug/71322
-local $ENV{LC_ALL} = 'C';
-all_pod_files_spelling_ok();
-
-__DATA__
-Wiki
-json
-APIs
-ActionClass
-Daisuke
-Daisuke
-Deserialize
-Deserializer
-Deserializing
-Doran
-Goulah
-JSON
-Laco
-Maki
-Maki
-Marchex
-Multipart
-Pearcey
-Rolsky
-RESTful
-RESTful
-SERIALIZERS
-TT
-Wikipedia
-XHR
-XMLHttpRequest
-YAML
-conf
-deserialization
-deserialize
-deserialized
-deserializing
-fREW
-html
-http
-javascript
-jrockway
-mst
-multipart
-namespace
-plugins
-request's
-serializer
-thusly
-wildcard
+++ /dev/null
-use strict;
-use warnings;
-use Test::More;
-
-use Test::Pod 1.14;
-
-all_pod_files_ok();
+++ /dev/null
-use strict;
-use warnings;
-
-use FindBin qw/$Bin/;
-use File::Spec;
-use File::Find::Rule;
-use Module::Info;
-
-use Test::More;
-
-my %versions;
-for my $pm_file ( File::Find::Rule->file->name( qr/\.pm$/ )->in(File::Spec->catdir($Bin, '..', 'lib') ) ) {
- my $mod = Module::Info->new_from_file($pm_file);
-
- ( my $stripped_file = $pm_file ) =~ s{.*/lib/}{};
-
- $versions{$stripped_file} = $mod->version;
-}
-
-my $ver = delete $versions{'Catalyst/Action/REST.pm'};
-ok $ver;
-ok scalar(keys %versions);
-
-for my $module ( sort keys %versions ) {
- is( $versions{$module}, $ver,
- "version for $module is the same as in Catalyst/Action/REST.pm" );
-}
-
-done_testing;
-