Initial commit of Catalyst-Action-REST
[catagits/Catalyst-Action-REST.git] / lib / Catalyst / Action / REST.pm
1 #
2 # REST.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
8 package Catalyst::Action::REST;
9
10 use strict;
11 use warnings;
12
13 use base 'Catalyst::Action';
14
15 sub dispatch {
16     my ( $self, $c ) = @_;
17
18     my $controller = $self->class;
19     my $method = $self->name . "_" . uc($c->request->method);
20     if ($controller->can($method)) {
21         $c->log->debug("REST ActionClass is calling $method");
22         return $controller->$method($c);
23     } else {
24         $c->log->debug("REST ActionClass is calling " . $self->name);
25         return $c->execute( $self->class, $self );
26     }
27 }
28
29 1;