Delayed template processing
Hi Everyone, What I'm looking for is a way to render a template with part of the results to the user to see while I continue processing and when I'm done I want to show the final template with all results. I'm currently using the new delayed method, which works fine for strings, but if I want to render templates it does not provide content until the very end, so no in-between output is produced, as I would like to show. Example code here: |get '/test/:*?' => sub { my $id = params->{'id'}; my $blub = params->{'blub'}; delayed { my $tt = Template->new( {INCLUDE_PATH => "$path", WRAPPER => 'layout.tt', RELATIVE => 1, }) || die "Template error: $Template::ERROR\n"; $tt->process('view.tt', { 'id' => $id, 'bla' => $blub }; content $tt; ### Process further push my @more, "String"; my $tt2 = Template->new( {INCLUDE_PATH => "$path", WRAPPER => 'layout.tt', RELATIVE => 1, }) || die "Template error: $Template::ERROR\n"; $tt2->process('view.tt', { 'id' => $id, 'bla' => $blub, 'more' => \@more }; content $tt2; done; }; }; | Is this possible or am I completely on the wrong track? Thanks, Joerg Phone: +43 1 4277 52732
I'd like to do the same thing. I haven't yet been able to identify at which point the streaming is failing (the browser? Apache proxy? Twiggy? Dancer?), and have been waiting to see if any of the Dancer2 team will explain things further. In case it is helpful, there is some more information on PSGI and streaming in the Catalyst advent calendar here: http://www.catalystframework.org/calendar/2013/10 (four part series) and the PSGI FAQ has some information on streaming: https://metacpan.org/pod/PSGI::FAQ#What-if-I-want-to-stream-content-or-do-a-... I haven't had a chance to do much research lately, but my next steps will be to find some other streaming PSGI apps to test (e.g. written with simple Plack, or some Catalyst or Mojolicious apps), to try to track down whether what we want to do is possible or whether the terminology is misleading. On 13 October 2015 at 06:51, Joerg Fallmann <fall@tbi.univie.ac.at> wrote:
Hi Everyone,
What I'm looking for is a way to render a template with part of the results to the user to see while I continue processing and when I'm done I want to show the final template with all results. I'm currently using the new delayed method, which works fine for strings, but if I want to render templates it does not provide content until the very end, so no in-between output is produced, as I would like to show. Example code here:
get '/test/:*?' => sub { my $id = params->{'id'}; my $blub = params->{'blub'}; delayed { my $tt = Template->new( {INCLUDE_PATH => "$path", WRAPPER => 'layout.tt', RELATIVE => 1, }) || die "Template error: $Template::ERROR\n"; $tt->process('view.tt', { 'id' => $id, 'bla' => $blub }; content $tt;
### Process further push my @more, "String"; my $tt2 = Template->new( {INCLUDE_PATH => "$path", WRAPPER => 'layout.tt', RELATIVE => 1, }) || die "Template error: $Template::ERROR\n"; $tt2->process('view.tt', { 'id' => $id, 'bla' => $blub, 'more' => \@more }; content $tt2; done; }; };
Is this possible or am I completely on the wrong track? Thanks, Joerg
Phone: +43 1 4277 52732
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
I'm trying to understand the issue here and what you want to do. Is it correct that the issue is that you (Joerg and Amelia) want to /push/ data to the user in multiple chunks? I do something similar with a push then a pull. I display the page with a template that has the header, some data and a footer. On load the page requests a different route through Dancer2 which populates the remaining data. In my case if the route is myhost/page, the page template requests myhost/pagedata (with appropriate parameters). --john On 10/13/2015 1:29 PM, Amelia Ireland wrote:
I'd like to do the same thing. I haven't yet been able to identify at which point the streaming is failing (the browser? Apache proxy? Twiggy? Dancer?), and have been waiting to see if any of the Dancer2 team will explain things further.
In case it is helpful, there is some more information on PSGI and streaming in the Catalyst advent calendar here:
http://www.catalystframework.org/calendar/2013/10 (four part series)
and the PSGI FAQ has some information on streaming:
https://metacpan.org/pod/PSGI::FAQ#What-if-I-want-to-stream-content-or-do-a-...
I haven't had a chance to do much research lately, but my next steps will be to find some other streaming PSGI apps to test (e.g. written with simple Plack, or some Catalyst or Mojolicious apps), to try to track down whether what we want to do is possible or whether the terminology is misleading.
On 13 October 2015 at 06:51, Joerg Fallmann <fall@tbi.univie.ac.at <mailto:fall@tbi.univie.ac.at>> wrote:
Hi Everyone,
What I'm looking for is a way to render a template with part of the results to the user to see while I continue processing and when I'm done I want to show the final template with all results. I'm currently using the new delayed method, which works fine for strings, but if I want to render templates it does not provide content until the very end, so no in-between output is produced, as I would like to show. Example code here:
|get '/test/:*?' => sub { my $id = params->{'id'}; my $blub = params->{'blub'}; delayed { my $tt = Template->new( {INCLUDE_PATH => "$path", WRAPPER => 'layout.tt <http://layout.tt>', RELATIVE => 1, }) || die "Template error: $Template::ERROR\n"; $tt->process('view.tt <http://view.tt>', { 'id' => $id, 'bla' => $blub }; content $tt; ### Process further push my @more, "String"; my $tt2 = Template->new( {INCLUDE_PATH => "$path", WRAPPER => 'layout.tt <http://layout.tt>', RELATIVE => 1, }) || die "Template error: $Template::ERROR\n"; $tt2->process('view.tt <http://view.tt>', { 'id' => $id, 'bla' => $blub, 'more' => \@more }; content $tt2; done; }; }; |
Is this possible or am I completely on the wrong track? Thanks, Joerg
Phone: +43 1 4277 52732
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm <mailto:dancer-users@dancer.pm> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
-- John J. McDermott, CPLP Learning and Performance Consultant jjm at jkintl.com 575/737-8556 Check out my security blog posts <http://cybersecurity.learningtree.com> Add an A for the Arts To STEM and get STEAM and a strong engine to move forward.
For this to work, you'd either need a template engine that is tightly integrated into Dancer or a streaming template engine (that would call a callback to call content as it got chunks) with the ability to loop over iterators or trigger callbacks to get more data to format. Though I guess you could use a normal template loop over a tied array too. But I don't know of such a template engine.
To circumvent this I thought about forwarding to another route after processing a template, this should actually work around the update existing output problem, but it seems this is not possible either so I really got no idea how to proceed at the moment. --joerg On 10/16/2015 09:05 AM, Yitzchak Scott-Thoennes wrote:
For this to work, you'd either need a template engine that is tightly integrated into Dancer or a streaming template engine (that would call a callback to call content as it got chunks) with the ability to loop over iterators or trigger callbacks to get more data to format. Though I guess you could use a normal template loop over a tied array too.
But I don't know of such a template engine.
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
Hi, I already asked around a bit about problems with delayed and how I could work around, but I thought the subject does not really fit anymore to my current problem. What I'm trying to do currently is to find a way to forward from routeA with parameters to routeB after the template has been processed and sent to the client. Does anybody know a way how this could work? Thanks for the help so far! --joerg
Is this the problem that you solved in your answer on the other related thread, or is this a separate issue? On 16 October 2015 at 04:50, Joerg Fallmann <fall@tbi.univie.ac.at> wrote:
Hi, I already asked around a bit about problems with delayed and how I could work around, but I thought the subject does not really fit anymore to my current problem.
What I'm trying to do currently is to find a way to forward from routeA with parameters to routeB after the template has been processed and sent to the client.
Does anybody know a way how this could work?
Thanks for the help so far! --joerg _______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
Hi, Sorry for the confusion, the problem is related, I solved it via javascript now, but would still like to know of any pure Dancer2 solution if there is one. --joerg On 10/16/2015 04:11 PM, Amelia Ireland wrote:
Is this the problem that you solved in your answer on the other related thread, or is this a separate issue?
On 16 October 2015 at 04:50, Joerg Fallmann <fall@tbi.univie.ac.at <mailto:fall@tbi.univie.ac.at>> wrote:
Hi, I already asked around a bit about problems with delayed and how I could work around, but I thought the subject does not really fit anymore to my current problem.
What I'm trying to do currently is to find a way to forward from routeA with parameters to routeB after the template has been processed and sent to the client.
Does anybody know a way how this could work?
Thanks for the help so far! --joerg _______________________________________________ dancer-users mailing list dancer-users@dancer.pm <mailto:dancer-users@dancer.pm> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
2015-10-16 6:50 GMT-05:00 Joerg Fallmann <fall@tbi.univie.ac.at>:
Hi, I already asked around a bit about problems with delayed and how I could work around, but I thought the subject does not really fit anymore to my current problem.
What I'm trying to do currently is to find a way to forward from routeA with parameters to routeB after the template has been processed and sent to the client.
Does anybody know a way how this could work?
#### snippet END OF ROUTE A ########## session username => $input_hash->{UName}; session UFname => $FN; session UID => $UID; session ScnName => $scn_name; redirect '/playerdash'; } template 'index';
2015-10-16 6:50 GMT-05:00 Joerg Fallmann <fall@tbi.univie.ac.at>:
Hi, I already asked around a bit about problems with delayed and how I could work around, but I thought the subject does not really fit anymore to my current problem.
What I'm trying to do currently is to find a way to forward from routeA with parameters to routeB after the template has been processed and sent to the client.
Does anybody know a way how this could work?
DID NOT MEAN TO SEND EARLIER MESSAGE ## SNIPPET End of Route A session username => $input_hash->{UName}; session UFname => $FN; session UID => $UID; session ScnName => $scn_name; redirect '/route_B'; } get '/route_B' => sub { my $uname = session 'username'; my $ufname= session 'UFname'; my $UID = session 'UID'; etc...
Other people have told you how to do this In your template have callbacks to OTHER routes that return the rest of the data as and when it’s available If you insist use the same route and figure out from a param whether its the initial call or a callback As far as I can tell once you have served a template that request is closed -- Clive Eisen GPG: 75056DD0
On 16 Oct 2015, at 11:31, Joerg Fallmann <fall@tbi.univie.ac.at> wrote:
To circumvent this I thought about forwarding to another route after processing a template, this should actually work around the update existing output problem, but it seems this is not possible either so I really got no idea how to proceed at the moment.
--joerg
On 10/16/2015 09:05 AM, Yitzchak Scott-Thoennes wrote:
For this to work, you'd either need a template engine that is tightly integrated into Dancer or a streaming template engine (that would call a callback to call content as it got chunks) with the ability to loop over iterators or trigger callbacks to get more data to format. Though I guess you could use a normal template loop over a tied array too.
But I don't know of such a template engine.
_______________________________________________ dancer-users mailing list
dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
Thanks to everyone involved I finally managed to get it done; For people with the same problem, here is an example for what I did, my $parameterhash; get '/routeA/:*?' => sub { my $id = params->{'id'}; my $blub = params->{'blub'}; delayed { my $tt = Template->new( {INCLUDE_PATH => "$path", WRAPPER => 'layout.tt', RELATIVE => 1, }) || die "Template error: $Template::ERROR\n"; $tt->process('view.tt', { 'id' => $id, 'bla' => $blub }; content $tt; done; ## Manual states from here on we can do whatever we want without intereferring with the stream $parameterhash = { 'id' => $id, 'bla' => $blub }; }; }; get '/routeB/:*?' => sub { ## parameters are now fetched from the parameterhash reference my $id = $parameterhash->{'id'}; my $blub = $parameterhash->{'bla'}; # Do something from here on my $addition = "something"; delayed { my $tt = Template->new( {INCLUDE_PATH => "$path", WRAPPER => 'layout.tt', RELATIVE => 1, }) || die "Template error: $Template::ERROR\n"; $tt->process('view2.tt', { 'id' => $id, 'bla' => $blub 'addition' => $addition }; content $tt; done; }; In the template view.tt I simply added <script type="text/javascript"> $(document).ready( function () { // Javascript URL redirection after 5 seconds setTimeout(function() { var str = window.location.href; var res = str.replace("routeA", "routeB"); window.location.replace(res); }, 5000); }); </script> which forwards to routeB, seems to work fine. The way I use it now I do not need delayed actually, but it doesn't hurt, so I keep for the moment. Thanks again to everybody! --joerg On 10/16/2015 01:51 PM, Clive Eisen wrote:
Other people have told you how to do this
In your template have callbacks to OTHER routes that return the rest of the data as and when it’s available
If you insist use the same route and figure out from a param whether its the initial call or a callback
As far as I can tell once you have served a template that request is closed
-- Clive Eisen GPG: 75056DD0
On 16 Oct 2015, at 11:31, Joerg Fallmann <fall@tbi.univie.ac.at> wrote:
To circumvent this I thought about forwarding to another route after processing a template, this should actually work around the update existing output problem, but it seems this is not possible either so I really got no idea how to proceed at the moment.
--joerg
On 10/16/2015 09:05 AM, Yitzchak Scott-Thoennes wrote:
For this to work, you'd either need a template engine that is tightly integrated into Dancer or a streaming template engine (that would call a callback to call content as it got chunks) with the ability to loop over iterators or trigger callbacks to get more data to format. Though I guess you could use a normal template loop over a tied array too.
But I don't know of such a template engine.
_______________________________________________ dancer-users mailing list
dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
Thanks for posting your example, this should be documented somewhere... but I also wonder if you really just need to put a <div> into your template and have your javascript just load more data from a seperate route into that div which could then scroll, re-draw, or whatever. Basically, if you have a long running process, how would you handle pagination of the results using your method? And what does your view2.tt contain as well? Joerg> Thanks to everyone involved I finally managed to get it done; Joerg> For people with the same problem, here is an example for what I did, Joerg> my $parameterhash; Joerg> get '/routeA/:*?' => sub { Joerg> my $id = params->{'id'}; Joerg> my $blub = params->{'blub'}; Joerg> delayed { Joerg> my $tt = Template->new( Joerg> {INCLUDE_PATH => "$path", Joerg> WRAPPER => 'layout.tt', Joerg> RELATIVE => 1, Joerg> }) || die "Template error: $Template::ERROR\n"; Joerg> $tt->process('view.tt', { Joerg> 'id' => $id, Joerg> 'bla' => $blub Joerg> }; Joerg> content $tt; Joerg> done; Joerg> ## Manual states from here on we can do whatever we want without intereferring with the stream Joerg> $parameterhash = Joerg> { Joerg> 'id' => $id, Joerg> 'bla' => $blub Joerg> }; Joerg> }; Joerg> }; Joerg> get '/routeB/:*?' => sub { Joerg> ## parameters are now fetched from the parameterhash reference Joerg> my $id = $parameterhash->{'id'}; Joerg> my $blub = $parameterhash->{'bla'}; Joerg> # Do something from here on Joerg> my $addition = "something"; Joerg> delayed { Joerg> my $tt = Template->new( Joerg> {INCLUDE_PATH => "$path", Joerg> WRAPPER => 'layout.tt', Joerg> RELATIVE => 1, Joerg> }) || die "Template error: $Template::ERROR\n"; Joerg> $tt->process('view2.tt', { Joerg> 'id' => $id, Joerg> 'bla' => $blub Joerg> 'addition' => $addition Joerg> }; Joerg> content $tt; Joerg> done; Joerg> }; Joerg> In the template view.tt Joerg> I simply added Joerg> <script type="text/javascript"> Joerg> $(document).ready( function () { Joerg> // Javascript URL redirection after 5 seconds Joerg> setTimeout(function() { Joerg> var str = window.location.href; Joerg> var res = str.replace("routeA", "routeB"); Joerg> window.location.replace(res); Joerg> }, 5000); Joerg> }); Joerg> </script> Joerg> which forwards to routeB, Joerg> seems to work fine. Joerg> The way I use it now I do not need delayed actually, Joerg> but it doesn't hurt, so I keep for the moment. Joerg> Thanks again to everybody! Joerg> --joerg Joerg> On 10/16/2015 01:51 PM, Clive Eisen wrote: Joerg> Other people have told you how to do this Joerg> In your template have callbacks to OTHER routes that return the rest of the data as and when it’s available Joerg> If you insist use the same route and figure out from a param whether its the initial call or a callback Joerg> As far as I can tell once you have served a template that request is closed Joerg> -- Joerg> Clive Eisen Joerg> GPG: 75056DD0 Joerg> On 16 Oct 2015, at 11:31, Joerg Fallmann <fall@tbi.univie.ac.at> wrote: Joerg> To circumvent this I thought about forwarding to another route Joerg> after processing a template, Joerg> this should actually work around the update existing output problem, Joerg> but it seems this is not possible either Joerg> so I really got no idea how to proceed at the moment. Joerg> --joerg Joerg> On 10/16/2015 09:05 AM, Yitzchak Scott-Thoennes wrote: Joerg> For this to work, you'd either need a template engine that is tightly integrated into Dancer or a streaming template engine (that would call a callback to call content as it got chunks) with the ability to loop over iterators or trigger callbacks to get more data to format. Though I guess you could use a normal template loop over a tied array too. Joerg> But I don't know of such a template engine. Joerg> _______________________________________________ Joerg> dancer-users mailing list Joerg> dancer-users@dancer.pm Joerg> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users Joerg> _______________________________________________ Joerg> dancer-users mailing list Joerg> dancer-users@dancer.pm Joerg> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users Joerg> _______________________________________________ Joerg> dancer-users mailing list Joerg> dancer-users@dancer.pm Joerg> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users Joerg> _______________________________________________ Joerg> dancer-users mailing list Joerg> dancer-users@dancer.pm Joerg> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
Hi, In my view2.tt I call AJAX which loads the rest of the data from other routes, so pretty much as you described. Parameter passing is now done via session cookies and handling of the results is done via datatables. Once I'm done with my app I can write some documentation and put it somewhere --joerg On 10/16/2015 05:05 PM, John Stoffel wrote:
Thanks for posting your example, this should be documented somewhere... but I also wonder if you really just need to put a <div> into your template and have your javascript just load more data from a seperate route into that div which could then scroll, re-draw, or whatever.
Basically, if you have a long running process, how would you handle pagination of the results using your method? And what does your view2.tt contain as well?
Joerg> Thanks to everyone involved I finally managed to get it done;
Joerg> For people with the same problem, here is an example for what I did,
Joerg> my $parameterhash; Joerg> get '/routeA/:*?' => sub { Joerg> my $id = params->{'id'}; Joerg> my $blub = params->{'blub'}; Joerg> delayed { Joerg> my $tt = Template->new( Joerg> {INCLUDE_PATH => "$path", Joerg> WRAPPER => 'layout.tt', Joerg> RELATIVE => 1, Joerg> }) || die "Template error: $Template::ERROR\n"; Joerg> $tt->process('view.tt', { Joerg> 'id' => $id, Joerg> 'bla' => $blub Joerg> }; Joerg> content $tt; Joerg> done; Joerg> ## Manual states from here on we can do whatever we want without intereferring with the stream Joerg> $parameterhash = Joerg> { Joerg> 'id' => $id, Joerg> 'bla' => $blub Joerg> }; Joerg> }; Joerg> };
Joerg> get '/routeB/:*?' => sub { Joerg> ## parameters are now fetched from the parameterhash reference Joerg> my $id = $parameterhash->{'id'}; Joerg> my $blub = $parameterhash->{'bla'};
Joerg> # Do something from here on Joerg> my $addition = "something"; Joerg> delayed { Joerg> my $tt = Template->new( Joerg> {INCLUDE_PATH => "$path", Joerg> WRAPPER => 'layout.tt', Joerg> RELATIVE => 1, Joerg> }) || die "Template error: $Template::ERROR\n"; Joerg> $tt->process('view2.tt', { Joerg> 'id' => $id, Joerg> 'bla' => $blub Joerg> 'addition' => $addition Joerg> }; Joerg> content $tt; Joerg> done; Joerg> };
Joerg> In the template view.tt Joerg> I simply added
Joerg> <script type="text/javascript"> Joerg> $(document).ready( function () { Joerg> // Javascript URL redirection after 5 seconds Joerg> setTimeout(function() { Joerg> var str = window.location.href; Joerg> var res = str.replace("routeA", "routeB"); Joerg> window.location.replace(res); Joerg> }, 5000); Joerg> }); Joerg> </script>
Joerg> which forwards to routeB, Joerg> seems to work fine.
Joerg> The way I use it now I do not need delayed actually, Joerg> but it doesn't hurt, so I keep for the moment.
Joerg> Thanks again to everybody!
Joerg> --joerg
Joerg> On 10/16/2015 01:51 PM, Clive Eisen wrote:
Joerg> Other people have told you how to do this
Joerg> In your template have callbacks to OTHER routes that return the rest of the data as and when it’s available
Joerg> If you insist use the same route and figure out from a param whether its the initial call or a callback
Joerg> As far as I can tell once you have served a template that request is closed
Joerg> -- Joerg> Clive Eisen Joerg> GPG: 75056DD0
Joerg> On 16 Oct 2015, at 11:31, Joerg Fallmann <fall@tbi.univie.ac.at> wrote:
Joerg> To circumvent this I thought about forwarding to another route Joerg> after processing a template, Joerg> this should actually work around the update existing output problem, Joerg> but it seems this is not possible either Joerg> so I really got no idea how to proceed at the moment.
Joerg> --joerg
Joerg> On 10/16/2015 09:05 AM, Yitzchak Scott-Thoennes wrote:
Joerg> For this to work, you'd either need a template engine that is tightly integrated into Dancer or a streaming template engine (that would call a callback to call content as it got chunks) with the ability to loop over iterators or trigger callbacks to get more data to format. Though I guess you could use a normal template loop over a tied array too.
Joerg> But I don't know of such a template engine.
Joerg> _______________________________________________ Joerg> dancer-users mailing list
Joerg> dancer-users@dancer.pm Joerg> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
Joerg> _______________________________________________ Joerg> dancer-users mailing list Joerg> dancer-users@dancer.pm Joerg> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
Joerg> _______________________________________________ Joerg> dancer-users mailing list Joerg> dancer-users@dancer.pm Joerg> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
Joerg> _______________________________________________ Joerg> dancer-users mailing list Joerg> dancer-users@dancer.pm Joerg> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users _______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
Den 2015-10-16 kl. 15:11, skrev Joerg Fallmann:
Thanks to everyone involved I finally managed to get it done; According to [1]|server push (with |||multipart/x-mixed-replace <https://en.wikipedia.org/wiki/MIME#Mixed-Replace>) |seems to still be supported by many browsers (with the obvious exception of IE) despite being abandoned by every one as IE never picked up the ball|
Has anyone tried it with Dancer? [1] https://en.wikipedia.org/wiki/Push_technology#HTTP_server_push (No, I don't think this is off-topic)
2015-10-16 16:11 GMT+03:00 Joerg Fallmann <fall@tbi.univie.ac.at>:
Thanks to everyone involved I finally managed to get it done;
For people with the same problem, here is an example for what I did,
my $parameterhash; get '/routeA/:*?' => sub {
Maybe you are thought on that, but to be clear, your example is basically equal to following: my $parameterhash; get '/routeA' => sub { my $id = params->{'id'}; my $blub = params->{'blub'}; $parameterhash = { 'id' => $id, 'bla' => $blub }; return "routeA: $id $blub"; }; get '/routeB' => sub { my $id = $parameterhash->{'id'}; my $blub = $parameterhash->{'bla'}; return "routeB: $id $blub"; }; Without some serious counter measures this pattern has huge security problem. If any user points routeA, then any other request to routeB has same data available. Wbr, -- Kõike hääd, Gunnar
Hi, You are of course absolutely right, my idea of a workaround was to implement sessions into my app. I now store some variables from one route in cookies to be able to retrieve those variables from other routes. So far this seems to work fine and should solve the problem --joerg On 10/16/2015 06:34 PM, WK wrote:
2015-10-16 16:11 GMT+03:00 Joerg Fallmann <fall@tbi.univie.ac.at>:
Thanks to everyone involved I finally managed to get it done;
For people with the same problem, here is an example for what I did,
my $parameterhash; get '/routeA/:*?' => sub { Maybe you are thought on that, but to be clear, your example is basically equal to following:
my $parameterhash;
get '/routeA' => sub { my $id = params->{'id'}; my $blub = params->{'blub'};
$parameterhash = { 'id' => $id, 'bla' => $blub };
return "routeA: $id $blub"; };
get '/routeB' => sub { my $id = $parameterhash->{'id'}; my $blub = $parameterhash->{'bla'};
return "routeB: $id $blub"; };
Without some serious counter measures this pattern has huge security problem. If any user points routeA, then any other request to routeB has same data available.
Wbr,
participants (9)
-
Amelia Ireland -
Christian Huldt -
Clive Eisen -
Joerg Fallmann -
John J. McDermott, CPLP -
John Stoffel -
Richard Reina -
WK -
Yitzchak Scott-Thoennes