Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OPTIONS requests and not implemented methods. #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/Catalyst/Action/REST.pm
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ sub _get_allowed_methods {
my ( $self, $controller, $c, $name ) = @_;
my $class = ref($controller) ? ref($controller) : $controller;
my $methods = Class::Inspector->methods($class);
return map { /^$name\_(.+)$/ } @$methods;
return map { /^$name\_([^[:lower:]]+)$/ } @$methods;
};

sub _return_options {
Expand All @@ -158,7 +158,8 @@ sub _return_not_implemented {
$c->response->body( "Method "
. $c->request->method
. " not implemented for "
. $c->uri_for( $method_name ) );
. $c->req->uri );
$c->log->debug( "Not implemented for: " . $c->uri_for( $method_name ) ) if $c->debug;
}

__PACKAGE__->meta->make_immutable;
Expand Down
8 changes: 8 additions & 0 deletions t/catalyst-action-rest.t
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ is(
"not_implemented handler had proper response"
);

my $ni_def_res = request( $t->delete( url => '/default/not_implemented/a/b' ) );
is( $ni_def_res->code, 405, "Default not_implemented handler succeeded" );
like(
$ni_def_res->content,
qr|Method.*?http://.*?/default/not_implemented/a/b$|,
"Default not_implemented handler had proper path for response"
);

1;

done_testing;
10 changes: 10 additions & 0 deletions t/lib/Test/Catalyst/Action/REST/Controller/Root.pm
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ sub notreally_GET {
$c->forward('ok');
}

sub notreally_TeSt : Local {
my ( $self, $c ) = @_;

$c->stash->{'entity'} = "notreally test";
$c->forward('ok');
}

sub not_implemented : Local : ActionClass('REST') {
}

Expand All @@ -75,6 +82,9 @@ sub not_implemented_not_implemented {
$c->forward('ok');
}

sub default_not_implemented : Path('/default/not_implemented') : Args(2) : ActionClass('REST') {
}

sub not_modified : Local : ActionClass('REST') { }

sub not_modified_GET {
Expand Down