[Dancer-users] alternate routes based on where the query is coming from
Puneet Kishor
punk.kish at gmail.com
Sun Feb 27 04:15:09 CET 2011
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
==================================================================
More information about the Dancer-users
mailing list