« index
Coverage for /Users/yunong/workspace/node-restify/lib/formatters/text.js : 100%
20 lines |
20 run |
0 missing |
0 partial |
4 blocks |
4 blocks run |
0 blocks missing
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | // Copyright 2012 Mark Cavage, Inc. All rights reserved. ///--- Exports function formatText(req, res, body) { if (body instanceof Error) { res.statusCode = body.statusCode || 500; body = body.message; } else if (typeof (body) === 'object') { body = JSON.stringify(body); } else { body = body.toString(); } res.setHeader('Content-Length', Buffer.byteLength(body)); return (body); } module.exports = formatText; |