X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Action-Serialize-Data-Serializer.git;a=blobdiff_plain;f=lib%2FCatalyst%2FAction%2FREST%2FForBrowsers.pm;fp=lib%2FCatalyst%2FAction%2FREST%2FForBrowsers.pm;h=0000000000000000000000000000000000000000;hp=22f1285c94c9101652865acf76a7541bb4c68b88;hb=79025f72c27ba313b3c701cee238f84166f32f9e;hpb=f10c7e1c7eb3b4cb10401dbb86ca8db3dc38ced2 diff --git a/lib/Catalyst/Action/REST/ForBrowsers.pm b/lib/Catalyst/Action/REST/ForBrowsers.pm deleted file mode 100644 index 22f1285..0000000 --- a/lib/Catalyst/Action/REST/ForBrowsers.pm +++ /dev/null @@ -1,113 +0,0 @@ -package Catalyst::Action::REST::ForBrowsers; - -use Moose; -use namespace::autoclean; - -our $VERSION = '1.07'; -$VERSION = eval $VERSION; - -extends 'Catalyst::Action::REST'; -use Catalyst::Request::REST::ForBrowsers; - -sub BUILDARGS { - my $class = shift; - my $config = shift; - Catalyst::Request::REST::ForBrowsers->_insert_self_into( $config->{class} ); - return $class->SUPER::BUILDARGS( $config, @_ ); -} - -override dispatch => sub { - my $self = shift; - my $c = shift; - - my $req = $c->request(); - - return super() - unless $req->can('looks_like_browser') - && $req->looks_like_browser() - && uc $c->request()->method() eq 'GET'; - - my $controller = $c->component( $self->class ); - my $rest_method = $self->name() . '_GET_html'; - - if ( $controller->action_for($rest_method) - || $controller->can($rest_method) ) { - - return $self->_dispatch_rest_method( $c, $rest_method ); - } - - return super(); -}; - -__PACKAGE__->meta->make_immutable; - -1; - -=head1 NAME - -Catalyst::Action::REST::ForBrowsers - Automated REST Method Dispatching that Accommodates Browsers - -=head1 SYNOPSIS - - sub foo :Local :ActionClass('REST::ForBrowsers') { - ... do setup for HTTP method specific handlers ... - } - - sub foo_GET : Private { - ... do something for GET requests ... - } - - sub foo_GET_html : Private { - ... do something for GET requests from browsers ... - } - - sub foo_PUT : Private { - ... do something for PUT requests ... - } - -=head1 DESCRIPTION - -This class subclasses L to add an additional -dispatching hook. If the request is a GET request I the request looks -like it comes from a browser, it tries to dispatch to a C method -before trying to the C method instead. All other HTTP methods are -dispatched in the same way. - -For example, in the synopsis above, calling GET on "/foo" from a browser will -end up calling the C method. If the request is I from a -browser, it will call C. - -See L for more details on dispatching details. - -=head1 METHODS - -=over 4 - -=item dispatch - -This method overrides the default dispatch mechanism to the re-dispatching -mechanism described above. - -=back - -=head1 SEE ALSO - -You likely want to look at L, which implements a -sensible set of defaults for a controller doing REST. - -This class automatically adds the -L role to your request class. - -=head1 CONTRIBUTORS - -Dave Rolsky Eautarch@urth.orgE - -=head1 COPYRIGHT - -Copyright the above named AUTHOR and CONTRIBUTORS - -=head1 LICENSE - -You may distribute this code under the same terms as Perl itself. - -=cut