[dancer-users] Dancer1 v1.3124 on its way to CPAN

Yanick Champoux yanick at babyl.dyndns.org
Tue May 13 12:52:28 BST 2014

On 14-05-13 02:53 AM, Warren Young wrote:
>> hook before => sub {
>> >     my $url = request->uri;
>> >     redirect $url if $url =~ s#(?<=.)/$##;
>> >};
> I’m guessing the only reason you have that lookbehind in there is to prevent the substitution from breaking the top-level ‘/‘ route?

Yup, that's it.

> Also, is there anything wrong with using “forward” here instead of “redirect”?  I’d rather save the HTTP round-trip and not “correct” the browser, as my app really does not care.

Just switching the redirect for a forward will cause an error. But I 
think that with a judicious use of 'halt' and munging of the 'response' 
object, that'd be entirely possible.


More information about the dancer-users mailing list