[Dancer-users] separating code into packages

Gabor Szabo szabgab at gmail.com
Sat Dec 25 13:58:31 CET 2010


On Sat, Dec 25, 2010 at 1:35 PM, sawyer x <xsawyerx at gmail.com> wrote:
> On Sat, Dec 25, 2010 at 11:01 AM, Gabor Szabo <szabgab at gmail.com> wrote:
>>
>> In the end I found some other way. I am not sure if it is blessed by
>> the Dancer developers or not:
>>
>> my $prefix = Dancer::App->current->prefix();
>> load_app "Foo::User", prefix => "$prefix/user";
>> Dancer::App->current->prefix($prefix);
>
> Actually, I do something much simpler.
>
> I have a Foo::User.pm, which has:
> package Foo::User;
> use Dancer ':syntax';
> prefix '/user';
>
> get '/' => sub {...};
> get '/view/' => sub {...};
> --
>
> Then from Foo.pm, I set up:
> load path( qw/ Foo User.pm / );

That is indeed simpler but it will break if you mount
the whole Foo application to /xyz as your user will still
be at /user and not at /xyz/user

Gabor


More information about the Dancer-users mailing list