On 01/04/2009, at 10:47 AM, J. Shirley wrote:
On Tue, Mar 31, 2009 at 4:01 PM, <[email protected]> wrote:
hi all
In Ruby we can detect if the current form's request is a post or not.
def controller_action
if request.post?
# Process post data as the user has submitted the form.
else
# Display form
end
end
Looking at Catalyst::Request
(
http://search.cpan.org/~mramberg/Catalyst-Runtime-5.71001/lib/Catalyst/Request.pm#$req-%3Eprotocol
<http://search.cpan.org/%7Emramberg/Catalyst-Runtime-5.71001/lib/Catalyst/Request.pm#$req-%3Eprotocol
>
),
I found $req->method. The description says, "Contains the request
method
(GET, POST, HEAD, etc)."
So, in Catalyst, would it be sufficient for me to do something like:
...
Yes, as the docs say, that's what it is for :)
$c->req->method eq 'POST' will do what you want. You should not do
any
processing on a GET request, though. It is just bad practice.
Also from Catalyst::Request docs you have
$req->body_parameters ( or body_params ) for POST
$req->query_parameters for ( or query_params) GET
if you want to lump them together, just use $req->parameters or $req-
>params (not $req->param which is a disrecommended CGI.pm compat
method).
_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/