[Dancer-users] forward() and prefix

Brian E. Lozier brian at massassi.com
Fri May 18 15:35:37 CEST 2012


On Fri, May 18, 2012 at 1:21 AM, Alessandro Ranellucci <aar at cpan.org> wrote:
> Hello dancers,
>
> it looks like forward() doesn't imply the application prefix. This might
> even be a regression, but I'm not sure about this.
>
> For example:
>
> ===
> load_app 'Foo::Bar', prefix => '/foo';
>
> package Foo::Bar;
> use Dancer ':syntax';
>
> get '/'    => sub { forward '/baz' };
> get '/baz' => sub { "Hello world" };
> ===
>
> Calls to /foo/ from outside are correctly routed to the first handler, but
> then the forward fails because /baz is not internally prepended with the
> application prefix.
>
> A workaround is to add the prefix to the path supplied to forward()
> explicitely but this violates encapsulation.
>
> I think forward() should just prepend its first argument with the current
> application prefix before trying to route the request.
>
> Opinions? :)

Hmm, not convinced.  How would you forward to another path mounted at
a different directory (outside your current prefix)?  Maybe just
implement a forward_with_prefix() in your app?

>
> - Alessandro
>
> _______________________________________________
> Dancer-users mailing list
> Dancer-users at perldancer.org
> http://www.backup-manager.org/cgi-bin/listinfo/dancer-users


More information about the Dancer-users mailing list