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? :) - Alessandro
On Fri, May 18, 2012 at 1:21 AM, Alessandro Ranellucci <aar@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@perldancer.org http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
On 18-05-2012 at 15:35, Brian E. Lozier wrote:
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?
How does one app know the prefix it's mounted at? There seems to be no public API for that. I would agree with you if we were talking about "lexical" prefixes, set using the prefix() method. I'm talking about mount prefixes which you pass to the load_app() method, thus outside of the app itself. I don't think it's good design to forward() a request to another app. - Alessandro
participants (2)
-
Alessandro Ranellucci -
Brian E. Lozier