[dancer-users] Why is Dancer2 mixing POST and GET params?

Gabor Szabo gabor at szabgab.com
Sat Jan 10 10:49:34 GMT 2015


In the strange case of sending a POST request to


with the POSTed values b=4 and c=3

the param() function of dancer will return  1 for a, 3 for c as expected and
4 for b.

So it overrides the b received in the URL by the b received in the POST,
but it also supplies the value for a which is only available in the URL.

On the other hand, if the same key is supplied multiple times in the URL
then param('a') will return an array reference.

I wonder wouldn't it be better to have separate param() functions for
values received in the URL and values received in the POST request?
Or in other words, could someone explain why was the decision to unite
these input channels?

ps. This is the code I used:

package App::Try;
use Dancer2;

our $VERSION = '0.1';
use Data::Dumper;

get '/' => sub {
    '<form method="POST" action="/echo?a=1&b=2&a=6"><input name="c"
value="3"><input name="b" value="4"><input type="submit">';

post '/echo' => sub {
    return sprintf "%s - %s - %s", Dumper(param('a')),  param('b'),

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.preshweb.co.uk/pipermail/dancer-users/attachments/20150110/250e5584/attachment.html>

More information about the dancer-users mailing list