[Dancer-users] running a route from another route within Dancer

sawyer x xsawyerx at gmail.com
Tue Oct 25 15:52:23 CEST 2011


Dude... this is what functions are for.

You're stretching Dancer in incorrect ways, which gives you grief. You
should be opting for simple elegant coding solutions, and that's something
you can easily do using refactored subroutines.

get '/json/....' => sub { my_json_parsing_function(@_) };
get '/bar/:format' => sub { ...... my $result =
my_json_parsing_function("stuff"); [# do something with result...] };

Seriously... :)

On Tue, Oct 25, 2011 at 3:40 PM, Puneet Kishor <punk.kish at gmail.com> wrote:

> Is something like the following possible (see the line marked />+/)? Or,
> even advisable?
>
>        get '/foo.:format' => sub {
>                my $a = param 'a';
>                my $b = param 'b';
>
>                my $res = query_db($a, $b);
>                return to_json $res;
>        }
>
>        get '/bar.:format' => sub {
>                my $a = param 'a';
>                my $b = param 'b';
>
>        >>>>>>  my $res_foo = <somehow call /foo.json?a=$a&b=$b>;
>                my $res = do_something($res_foo);
>                return to_json $res;
>        }
>
> --
> Puneet Kishor
> _______________________________________________
> Dancer-users mailing list
> Dancer-users at perldancer.org
> http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.backup-manager.org/pipermail/dancer-users/attachments/20111025/c4fd50cb/attachment.htm>


More information about the Dancer-users mailing list