[Dancer-users] getting the routes info for `load_app` loaded apps

Richard Huxton dev at archonet.com
Fri Dec 2 16:37:14 CET 2011


On 02/12/11 15:01, Puneet Kishor wrote:
> I have written a plugin (modeled after Dancer::Plugin::SiteMap) that
[snip]
> Now I have an application where sub-applications are loaded using
>
> load_app 'app1', prefix ->  '/app1'; load_app 'app2', prefix ->
> '/app2';
>
> This also works rather well, except now my plugin doesn't work. My
> base app is reachable at `http://server/baseapp` so the following URI
> works `http://server/baseapp/meta/author` but
> `http://server/baseapp/app1/meta/author` doesn't work... I get the
> void.

If you have "get" calls as in Plugin::Sitemap then they'll get evaluated 
once, when the plugin gets loaded so it's not going to know anything 
about your sub-apps.

So - I would put them in a "register_routes" sub, and make sure that 
gets called when the plugin gets loaded. I'd also add an optional 
parameter that lets you set up a custom prefix.

Then, you can call register_routes to set up your meta routes for each 
sub-app.

I'm not sure where you get information like "author" from, but that 
process might need some tweaks too if it can be different for each app.


-- 
   Richard Huxton
   Archonet Ltd


More information about the Dancer-users mailing list