but when you say "ERRest will look at the request" -- isn't that what I'm trying to do?
or I should say, how should I bet implement this callback query argument is present?
aside from setting up a few keys for jsonp, at this time, I simply set the response header to _javascript_ and I "can" the callback method name.
you'll see I had written in some code which I figured would get the requested callback name and send via userInfo, which is obviously not needed.
so, can I somehow access the request from here? or how do I otherwise look at the request at the right time and do the right thing?
public class ERXJSONPRestWriter extends ERXJSONRestWriter {
public void appendHeadersToResponse(ERXRestRequestNode node, IERXRestResponse response, ERXRestContext context) {
response.setHeader("text/_javascript_;charset=UTF-8", "Content-Type");
}
public void appendToResponse(ERXRestRequestNode node, IERXRestResponse response, ERXRestFormat.Delegate delegate, ERXRestContext context) {
String callbackName = (String) context.userInfoForKey("callback");
if (callbackName != null)
response.appendContentString(callbackName + "(");
else
response.appendContentString("callback(");
node = processNode(node);
if (node != null) {
node._removeRedundantTypes();
}
appendHeadersToResponse(node, response, context);
Object object = node.toJavaCollection(delegate);
if (object == null) {
response.appendContentString("undefined");
}
else if (ERXRestUtils.isPrimitive(object)) {
response.appendContentString(String.valueOf(object));
}
else {
response.appendContentString(JSONSerializer.toJSON(object, configWithContext(context)).toString());
}
response.appendContentString(");");
}
}