In general, a Catalyst application should dispatch all HTTP methods to a matching action, based only on the path. So, the code you posted which checks $c->req->method is a correct approach and should work. Since it doesn't work, the next question is whether you have any special middleware or Catalyst plugins that are affecting things. I didn't answer your previous question in hopes that someone would recognize the specific scenario, but I guess nobody did.

One of the powerful features of Catalyst is the great degree of "hooking" that you can do at all phases of handling the request. The downside is that a lot of the flow control of the application becomes hidden and makes a learning curve for the maintenance developer. A developer or plugin author might decide to make POST requests opt-in rather than manually switching inside of each action, or something like that. Your challenge is to find out where that happened.

First, check all the plugins loaded at the top level

use Catalyst qw/ PLUGIN1 PLUGIN2 PLUGIN3 ... /;
and read their CPAN documentation.

Then, check for the base class of the controller.

use Moose; extends 'Catalyst::Controller'; # normal # vs... extends 'Catalyst::Controller::REST'; # changes behavior of things
Sometimes a project might also have a 'MyApp::Controller' base class used for all controllers where the author sets up the defaults they want to use for the project.

Check for the 'begin' and 'end' actions:

sub begin :SOME_MAGIC_ATTRIBUTE {}
or something more deliberate:
sub begin { my ($self, $c)= @_; if ($c->req->method ne 'GET') { $c->res->code(404); $c->detch; }

Then, check for behaviors of a parent controller, such as the root controller:

package MyApp::Controller::Root; sub begin { ... }
and any controller in the filesystem hierarchy leading to the one that is giving you problems.

You can also put debug statements in each of the begin/end places to help log what is going on.

Hope that helps.


In reply to Re: Help me understand Catalyst routing, or do I mean Actions? by NERDVANA
in thread Help me understand Catalyst routing, or do I mean Actions? by Cody Fendant

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.