Why not create a function like in next code:
var rs = new myResponse();
var rq = new myRequest();
c = new Function("myRequest","myResponse","myResponse.body = 'hello'; myResponse.end();");
// or
// c = new Function("myRequest,myResponse","myResponse.body = 'hello'; myResponse.end();");
c();
Or if you cannot, do next for example:
function stringToFunction(str) {
var m=str.match(/\s*function\((.*?)\)\s*{(.*?)}\s*/);
if(m)return new Function(m[1],m[2]);
}
var rs = new myResponse();
var rq = new myRequest();
c = "function(myRequest,myResponse){myResponse.body = 'hello'; myResponse.end();}";
stringToFunction(c)();
// or
//var f=stringToFunction(c);
//f();