[Dancer-users] alternate routes based on where the query is coming from

sawyer x xsawyerx at gmail.com
Sun Feb 27 11:23:59 CET 2011


Franck is putting a lot of work into the hooks right now. When those are
done, you should be able to use a hook to do it.

On Sun, Feb 27, 2011 at 5:15 AM, Puneet Kishor <punk.kish at gmail.com> wrote:

> now that I have the following working (thanks Matt Vickers)
>
> % curl 'http://dm.local/dm.json?var=prcp&from=1980-1-1&to=1980-2-2'
>
> I get back
>
> {"prcp": [0, 1, 2, 1, 0 ... lots of elements .. ]}
>
> Except, these values need to be post-processed before display/use. Because
> I get back so many values, I do the transfer as above, and then post process
> them in the user's browser using JavaScript.
>
> $.ajax({
> url : "/dm.json?var=" + v + "&from=" + from + "&to=" + to,
> type : "GET",
> data : "",
> dataType: "json",
> error : function() { alert("Error loading html document"); },
> success : function(d) {
> var dt = d[v];
> var data = [];
> for (var i = 0; i < dt.length; i++) {
> data.push( post_process(dt[i] );
> }
> ..
> display( data );
> }
> });
>
> Of course, I don't have recourse to JavaScript with curl, so I need to
> "post process" the data *before* it gets to the user, that is, I need to do
> it on the server side. Of course, I could do this with two different routes,
> one for via the browser, and the other via curl. But, surely, Dancer has
> some way more elegant pas de deux that can do this, no?
>
> Come to think of it, pas de deux would be a nice name for a Dancer plugin.
>
>
> --
> Puneet Kishor http://punkish.org
> Carbon Model http://carbonmodel.org
> Charter Member, Open Source Geospatial Foundation http://osgeo.org
> Science Fellow http://creativecommons.org
> Nelson Institute, UW-Madison http://nelson.wisc.edu
> ------------------------------------------------------------------
> Assertions are politics;
> Backing up assertions with evidence is science
> ==================================================================
>
>
> _______________________________________________
> 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/20110227/a483590d/attachment.htm>


More information about the Dancer-users mailing list