Le 24/08/2010 10:09, Peter Gordon a écrit :
When debugging a web app, I find it much easier if I can run the app like this:
perl -d myApp.pl color=red name=apple
Here is a way to go: package FooApp; use Dancer ':syntax'; our $VERSION = '0.1'; before sub { my $args = {}; for my $arg (@ARGV) { my ($key, $val) = split(/=/, $arg); $args->{$key} = $val; } request->_set_route_params($args); return 1; }; get '/' => sub { my $params = request->params; to_yaml($params); }; true; $ perl -d ./FooApp.pl color=red name=apple Loading DB routines from perl5db.pl version 1.32 Editor support available. Enter h or `h h' for help, or `man perldebug' for more help. main::(./FooApp.pl:4): load_app 'FooApp'; DB<1> n main::(./FooApp.pl:5): dance; DB<1>
Dancer server 13461 listening on http://0.0.0.0:3000 == Entering the development dance floor ...
$ curl http://0:3000/ --- color: red name: apple This is indeed a good idea and I think this hack would deserve a plugin, like Dancer::Debug::ParamsFromArgv or something alike. Happy dancing. -- Alexis Sukrieh