3 # Created by: Adam Jacob, Marchex, <adam@marchex.com>
4 # Created on: 10/12/2006 03:00:32 PM PDT
8 package Catalyst::Action::REST;
13 use base 'Catalyst::Action';
17 my ( $self, $c ) = @_;
19 my $controller = $self->class;
20 my $method = $self->name . "_" . uc( $c->request->method );
21 if ( $controller->can($method) ) {
22 return $controller->$method($c);
24 $self->_return_405($c);
25 return $c->execute( $self->class, $self );
30 my ( $self, $c ) = @_;
32 my $controller = $self->class;
33 my $methods = Class::Inspector->methods($controller);
35 foreach my $method ( @{$methods} ) {
36 my $name = $self->name;
37 if ( $method =~ /^$name\_(.+)$/ ) {
41 $c->response->content_type('text/plain');
42 $c->response->status(405);
43 $c->response->header( 'Allow' => \@allowed );
44 $c->response->body( "Method "
46 . " not implemented for "
47 . $c->uri_for( $self->reverse ) );