[dancer-users] Methods Of retrieving request parameters

Warren Young wyml at etr-usa.com
Tue Jul 12 16:01:56 BST 2016

On Jul 11, 2016, at 3:29 AM, Dave Cross <dave at dave.org.uk> wrote:

> The more explicitly-named methods are definitely safer. You really want to know where your parameters are coming from.

I’m still waiting for someone to justify that stance with more than confident prose assertions.  Someone, please show me code that the new keywords makes better.

If I’ve defined a route:

    get '/foo' => sub {
        my $bar = param 'bar';


…what practical difference does it make if my caller sends me the parameters in the URL or in the request body?  I’ve received a “bar” parameter, end of story. My program is satisfied.

The only case I can see is if you have two or more different ways to pass a given parameter, and they have different semantic meaning:

    get ‘/foo/:bar?' => sub {
        my $bar1 =  body_parameters->get('bar');
        my $bar2 = query_parameters->get('bar');
        my $bar3 = route_parameters->get('bar');
        if (defined $bar1) {
             # do one thing
        elsif (defined $bar2) {
             # do something completely different
        elseif (defined $bar3) {
             # do something different from both above options
        else {
             # emit flying monkeys

I submit that the above is horrible coding style, and no amount of keyword redesign in Dancer is going to fix the fundamental problem, that being PBD.


More information about the dancer-users mailing list