Skip to content

Instantly share code, notes, and snippets.

@deedubs
Created August 29, 2013 16:20
Show Gist options
  • Select an option

  • Save deedubs/6380253 to your computer and use it in GitHub Desktop.

Select an option

Save deedubs/6380253 to your computer and use it in GitHub Desktop.
function scrub (obj) {
for(var attr in obj) {
if(obj.hasOwnProperty(attr)) {
if (attr.charAt(1) === '_') {
obj[attr] = true;
}
}
}
return obj;
}
server.ext('onPostHandler', function (request, next) {
var response = request.response();
if (response.variety === 'obj') {
var raw = response.raw;
if (raw instanceof Array) {
response.raw = raw.map(scrub);
} else if (raw instanceof Object) {
response.raw = scrub(raw);
}
response.update();
}
next();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment