Acme-CPANModulesBundle-Import-PerlDancerAdvent-2018
view release on metacpan or search on metacpan
devdata/http_advent.perldancer.org_2018_22 view on Meta::CPAN
<p>For example:</p>
<pre class="prettyprint">use Dancer2;
get '/:id' => sub {
my $id = route_parameters->{'id'};
if ( $id !~ /^[0-9]+$/ ) {
send_error 'Bad ID' => 400;
}
# optional
my $action = query_parameters->{'action'};
unless ( defined $action && length $action ) {
send_error 'Bad Action' => 400;
}
# use $id and maybe $action
};</pre>
<p>The more parameters we have, the more annoying it is to write these
tests.</p>
<p>But what's more revealing here is that this validation code is not
actually part of our web code. It's input validation <i>for</i> our web
( run in 0.690 second using v1.01-cache-2.11-cpan-65fba6d93b7 )