Created
August 29, 2013 16:20
-
-
Save deedubs/6380253 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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