[cgiapp] REST tunneling in CGI::Application::Dispatch
Jaldhar H. Vyas
jaldhar at braincells.com
Fri Jul 1 02:55:51 EDT 2011
On Thu, 30 Jun 2011, Mark Stosberg wrote:
> How would you recommend he use REST::Util here. His "diff" is only a few
> lines and does very little. See it here:
>
> https://github.com/tima/CGI--Application--Dispatch/commit/1e906a01f9470b3b15894e4c77e10c0e8468c86b
>
This bit:
if($tunneling && $http_method eq 'POST') {
$rm = sub {
my $self = shift;
my $rest_method = $self->query->param('_method') ||
'POST';
$rest_method = lc $rest_method if $method_lc;
return $rm.'_'.$rest_method;
};
} else {
$http_method = lc $http_method if $method_lc;
$rm .= "_$http_method";
}
could be replaced by:
if($tunneling && $http_method eq 'POST') {
my $rest_method = request_method($self->query);
$rest_method = lc $rest_method if $method_lc;
return $rm.'_'.$rest_method";
} else {
$http_method = lc $http_method if $method_lc;
$rm .= "_$http_method";
}
}
This gets you a wider variety of tunneling behaviors. (see the docs for
request_method in REST::Utils)
The bigger win would be to enable C::A::Dispatch to dispatch based on MIME
type but that would require a more invasive patch.
--
Jaldhar H. Vyas <jaldhar at braincells.com>
More information about the cgiapp
mailing list