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

Puneet Kishor punk.kish at gmail.com
Fri Dec 2 16:01:26 CET 2011


I have written a plugin (modeled after Dancer::Plugin::SiteMap) that allows me to create a few standard routes that are available in all applications. For example, by adding my plugin (I call it Dancer::Plugin::Meta), my applications automatically get a route called http://server/app/meta/author which returns the author information set in the config file.

This works rather well, and has become a key part of the app (there are other fairly useful routes besides author that get added, such as license, version, and most importantly, a listing of all the routes much like the SiteMap).

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.

Additionally, while `http://server/baseapp/meta/author` works, `http://server/baseapp/meta/resources` does not work. Normally, /meta/resources returns a listing of all the resources, but now I get the following error

"Serializer (Dancer::Serializer::JSON) failed at serializing HASH(0x7f9ae4696f00):\nencountered object '(?^:^\\/baseapp(?:\\/)?$)', but neither allow_blessed nor convert_blessed settings are enabled at /opt/local/lib/perl5/site_perl/5.14.1/JSON.pm line 154.\n"

Would appreciate any guidance on how to retrieve all the URIs for the app loaded using load_app and resolving the above errors.

--
Puneet Kishor


More information about the Dancer-users mailing list