[dancer-users] Methods Of retrieving request parameters

Kadir Beyazlı kadirbeyazli at gmail.com
Mon Jul 11 09:59:09 BST 2016


Hi,

At my projects I always used params hash reference to retrieve request
parameters as follow:

get '/hello/:name' => sub {
    return "Hi there " . params->{name};
};

I started reading Dancer ManuaI again to discover new features whether
I missed and realized that using following ones are safer:

route_parameters->get('name');
query_parameters->get('name');

There is also param('name') method. As a result I see that there are 4 ways:

get '/hello/:name' => sub {
    return "Hi there " . params->{name};
    # or
    return "Hi there " . route_parameters->get('name');
    # or
    return "Hi there " . query_parameters->get('name');
    # or
    return "Hi there " . param('name');

};

Is there any technical difference between these ways that one of them
can work at a special case but others don't?

If there is no difference except being safer (I got this info from
manual), is the reason of this diversity to support  Perl motto
TMTOWTDI?

Which ones are you using at your projects?

Thanks

Kadir Beyazlı
GSM : +90 535 821 50 00


More information about the dancer-users mailing list