<div dir="ltr">







<p class=""><span class="">Hi Gabor,</span></p>
<p class=""><span class=""></span><br></p>
<p class=""><span class="">that’s weird but interesting :)</span></p>
<p class=""><span class="">Through documentation you can find at <a href="http://search.cpan.org/~sukria/Dancer2-0.01/lib/Dancer2/Core/Request.pm#params($source)"><span class="">http://search.cpan.org/~sukria/Dancer2-0.01/lib/Dancer2/Core/Request.pm#params($source)</span></a></span></p>
<p class=""><span class=""></span>this:</p>
<p class=""><span class=""><b><i>Fetching only params from a given source</i></b></span></p>
<p class=""><span class="">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).</span></p>
<p class=""><span class="">In practical terms, this means that if the param </span><span class="">foo</span><span class=""> is passed both on the querystring and in a POST body, </span><span class="">you can only access one of them</span><span class="">.</span></p>
<p class=""><span class="">If you want to see only params from a given source, you can say so by passing the </span><span class="">$source</span><span class=""> param to </span><span class="">params()</span><span class="">:</span></p>
<p class=""><span class="">    my %querystring_params = params('query');</span></p>
<p class=""><span class="">    my %route_params       = params('route');</span></p>
<p class=""><span class="">    my %post_params        = params('body');</span></p>
<p class=""><span class="">If source equals </span><span class="">route</span><span class="">, then only params parsed from the route pattern are returned.</span></p>
<p class=""><span class="">If source equals </span><span class="">query</span><span class="">, then only params parsed from the query string are returned.</span></p>
<p class=""><span class="">If source equals </span><span class="">body</span><span class="">, then only params sent in the request body will be returned.</span></p>
<p class=""><span class="">If another value is given for </span><span class="">$source</span><span class="">, then an exception is triggered.</span></p>
<p class=""><span class=""></span><br></p>
<p class="">So it means you can get params from different sources.</p>
<p class=""><span class="">I believe Dancer 1 behaves the same way ( <a href="http://search.cpan.org/~xsawyerx/Dancer-1.3110/lib/Dancer/Request.pm"><span class="">http://search.cpan.org/~xsawyerx/Dancer-1.3110/lib/Dancer/Request.pm</span></a> )</span></p>
<p class=""><span class=""></span><br></p>
<p class=""><span class="">cheers,</span></p>
<p class=""><span class="">Tiago Q</span></p></div><div class="gmail_extra"><br><div class="gmail_quote">On 10 January 2015 at 12:31, Russell Jenkins <span dir="ltr"><<a href="mailto:russell.jenkins@strategicdata.com.au" target="_blank">russell.jenkins@strategicdata.com.au</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hey Gabor.<span class=""><br>
<br>
On 10/01/2015 9:49 pm, Gabor Szabo wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
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?<br>
</blockquote>
<br></span>
You can use the `params` keyword to access the various sources of params including 'query', 'route', or 'body'.<br>
eg.<br>
  my $body_params = params('body'); #hashref of only the body params<span class=""><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Or in other words, could someone explain why was the decision to unite these input channels?<br>
<br>
</blockquote></span>
This is what Sinatra does and hence what Dancer does.<br>
<br>
Hope that helps,<br>
   Russell.<br>
<br>
______________________________<u></u>_________________<br>
dancer-users mailing list<br>
<a href="mailto:dancer-users@dancer.pm" target="_blank">dancer-users@dancer.pm</a><br>
<a href="http://lists.preshweb.co.uk/mailman/listinfo/dancer-users" target="_blank">http://lists.preshweb.co.uk/<u></u>mailman/listinfo/dancer-users</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Tiago Quintela</div>
</div>