Reaching a route defined at another .pm file
Hi All, At my project all routes are defined at same file : myproject.pm as follow: get /product { } get /store { } get /user { } Then I decided to put each logical item into separate file as follow, for example I created Product.pm for product operations. #Product.pm package Product; use Dancer2; get /product { } At file myproject.pm I added package Product as follow and removed route from this file myproject.pm package myproject; use Dancer2; use Dancer2::Plugin::Database; use Product; But it can not find get /product route which was working when it was at myproject.pm How can I do it? -- Kadir Beyazlı GSM : +90 535 821 50 00
Hi All, I added 6th and 8th line to file bin/app.psgi and it found route defined at Product.pm but this time the routes defined at myproject.pm are not working #!/usr/bin/env perl 1 use strict; 2 use warnings; 3 use FindBin; 4 use lib "$FindBin::Bin/../lib"; 5 use myproject; 6 use Product; 7 adopen->to_app; 8 Product->to_app; On Sun, Sep 13, 2015 at 3:43 PM, Kadir Beyazlı <kadirbeyazli@gmail.com> wrote:
Hi All,
At my project all routes are defined at same file : myproject.pm as follow:
get /product {
}
get /store {
}
get /user {
}
Then I decided to put each logical item into separate file as follow, for example I created Product.pm for product operations.
#Product.pm package Product; use Dancer2;
get /product {
}
At file myproject.pm I added package Product as follow and removed route from this file
myproject.pm
package myproject; use Dancer2; use Dancer2::Plugin::Database; use Product;
But it can not find get /product route which was working when it was at myproject.pm
How can I do it?
-- Kadir Beyazlı GSM : +90 535 821 50 00
-- Kadir Beyazlı Computer Engineer GSM : +90 535 821 50 00
On 13/09/2015 10:43 pm, Kadir Beyazlı wrote:
How can I do it?
There was an article about this in the 2014 advent series: http://advent.perldancer.org/2014/10 The rest of last years advent articles are worth reading too. ( Sawyer++ ) Regards, Russell.
Hi Russell, Thank you very much, it worked! 3rd line solved problem! 1 #Product.pm 2 package Product; 3 use Dancer2 appname => 'myproject'; get /product { } But while reading article, I realized another issue; Now my main application file is myproject.pm And I am applying following command to restart application cd myproject plackup -r bin/app.psgi At article you sent, it uses .pl file as follow # app.pl use myproject; use Product; # single application composed of routes provided in multiple files project->to_app; Which one is better? If recommended method is using app.pl, at which directory should it be? On Sun, Sep 13, 2015 at 3:59 PM, Russell Jenkins <russell.jenkins@strategicdata.com.au> wrote:
On 13/09/2015 10:43 pm, Kadir Beyazlı wrote:
How can I do it?
There was an article about this in the 2014 advent series: http://advent.perldancer.org/2014/10
The rest of last years advent articles are worth reading too. ( Sawyer++ )
Regards, Russell.
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
-- Kadir Beyazlı Computer Engineer GSM : +90 535 821 50 00
On 13/09/2015 11:15 pm, Kadir Beyazlı wrote:
Which one is better? If recommended method is using app.pl, at which directory should it be?
If you are always starting your app via plackup (or some other psgi server), using bin/app.psgi is the typically used approach. Regards, Russell. ps. TIMTOWTDI
participants (2)
-
Kadir Beyazlı -
Russell Jenkins