[dancer-users] Why is Dancer2 mixing POST and GET params?
kintela at gmail.com
Sat Jan 10 17:03:18 GMT 2015
that’s weird but interesting :)
Through documentation you can find at
*Fetching only params from a given source*
If a required source isn't specified, a mixed hashref (or list of key value
pairs, in list context) will be returned; this will contain params from all
sources (route, query, body).
In practical terms, this means that if the param foo is passed both on the
querystring and in a POST body, you can only access one of them.
If you want to see only params from a given source, you can say so by
passing the $source param to params():
my %querystring_params = params('query');
my %route_params = params('route');
my %post_params = params('body');
If source equals route, then only params parsed from the route pattern are
If source equals query, then only params parsed from the query string are
If source equals body, then only params sent in the request body will be
If another value is given for $source, then an exception is triggered.
So it means you can get params from different sources.
I believe Dancer 1 behaves the same way (
On 10 January 2015 at 12:31, Russell Jenkins <
russell.jenkins at strategicdata.com.au> wrote:
> Hey Gabor.
> On 10/01/2015 9:49 pm, Gabor Szabo wrote:
>> 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?
> You can use the `params` keyword to access the various sources of params
> including 'query', 'route', or 'body'.
> my $body_params = params('body'); #hashref of only the body params
> Or in other words, could someone explain why was the decision to unite
>> these input channels?
>> This is what Sinatra does and hence what Dancer does.
> Hope that helps,
> dancer-users mailing list
> dancer-users at dancer.pm
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the dancer-users