[Dancer-users] running a route from another route within Dancer
Puneet Kishor
punk.kish at gmail.com
Tue Oct 25 16:01:09 CEST 2011
On Oct 25, 2011, at 8:52 AM, sawyer x wrote:
> Dude... this is what functions are for.
>
> You're stretching Dancer in incorrect ways, which gives you grief.
Not to worry... I hadn't yet stretched Dancer in incorrect ways, but did flirt with the idea of doing so, so asked before venturing forward.
Fwiw, I have already have had the program implemented as you suggested below, but for my own edification, and for future architectural purposes, I was contemplating doing a tango move on a ballroom dancer.
> 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
>>
> _______________________________________________
> Dancer-users mailing list
> Dancer-users at perldancer.org
> http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
More information about the Dancer-users
mailing list