R/getjsonp.R

Defines functions getjsonp dogetjsonp

# TODO: Add comment
# 
# Author: jeroen
###############################################################################

getjsonp <- function(fnargs){
	CONTENTTYPE <- "text/plain; charset=UTF8";
	mytempfile <- do.call(dogetjsonp, fnargs);
	return(list(filename = mytempfile, type = CONTENTTYPE));
}

dogetjsonp <- function(`!prefix` = "opencpu_jsonp_handler", ...){
	
	#redirect entire thing to json handler
	oldfile <- dogetjson(...);
	
	#add the padding
	newfile <- tempfile();
	cat(paste(`!prefix`, "(", sep=""), readLines(oldfile), ")", file=newfile, sep="\n");
	return(newfile);	
}
	
jeroenooms/opencpu-legacy documentation built on May 19, 2019, 6:15 a.m.