use Dancer; my $max_url_length = 100; # change this to what you want # first route handler any ['get', 'post'] => '.*' => sub { if ((length request->request_uri) > $max_url_length) { # do the 414 error page } else {pass(...);} }; # create other routes dance;