hi,
In the strange case of sending a POST request to
http://localhost:5000/echo?a=1&b=2
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 (e.g.
http://localhost:5000/echo?a=1&b=2&a=6
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?
Gabor
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'), param('c');
};
true;