Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Catalyst::TraitFor::Request::REST::ForBrowsers not creating _html method for POST

by uG (Scribe)
on Apr 26, 2011 at 15:58 UTC ( #901385=perlquestion: print w/ replies, xml ) Need Help??
uG has asked for the wisdom of the Perl Monks concerning the following question:

around method => sub { my $orig = shift; my $self = shift; return $self->$orig(@_) if @_ || $self->_determined_real_method; my $method = $self->$orig(); my $tunneled; if ( defined $method && uc $method eq 'POST' ) { $tunneled = $self->param('x-tunneled-method') || $self->header('x-http-method-override'); } $self->$orig( defined $tunneled ? uc $tunneled : $method ); $self->_determined_real_method(1); return $self->$orig(); };
This piece of code is from Catalyst::TraitFor::Request::REST::ForBrowsers I am using the action class REST::ForBrowsers and if a GET request is sent from a browser, methodname_GET_html gets called (otherwise just methodname_GET is called). However during a POST from a browser (and not sending x-tunneled-method or setting the x-http-method-override header) it is setting the boolean ($c->request->looks_like_browser) to 1, yet it calls the non browser sub methodname_POST (and not methodname_POST_html). I assume this is the problem piece of code since the trait is identifying the browser correctly.
Example:
sub user_GET_html : Private { my($self, $c) = @_; $c->log->debug('GET request from browser'); $c->log->debug('Called during browser GET requests only'); } sub user_POST : Private { my($self, $c) = @_; $c->log->debug('POST request from non-browser'); $c->log->debug('But I do think its a browser. WTF mate?') if $c->r +equest->looks_like_browser; #this should be false due to the method n +ame we are in } sub user_POST_html : Private { my($self, $c) = @_; $c->log->debug('POST request from browser'); $c->log->debug(' Nobody ever calls me :( '); }
EDIT: So the reason is because in Catalyst::Actin::REST it only checks the traits for a GET request. Is there some sort of reason for this?

Comment on Catalyst::TraitFor::Request::REST::ForBrowsers not creating _html method for POST
Select or Download Code
Re: Catalyst::TraitFor::Request::REST::ForBrowsers not creating _html method for POST
by Anonymous Monk on Apr 28, 2011 at 06:54 UTC
    .... EDIT: So the reason is because in Catalyst::Actin::REST it only checks the traits for a GET request. Is there some sort of reason for this?

    FWIW, I assume its a requirement of REST , maybe :) The maintainers/developers probably know for sure ;)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://901385]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2015-07-07 04:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (87 votes), past polls