Skip to content
This repository has been archived by the owner on Sep 28, 2024. It is now read-only.

Commit

Permalink
Update formatters
Browse files Browse the repository at this point in the history
  • Loading branch information
marsanla committed Dec 31, 2014
1 parent 13da834 commit 7acb92c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
7 changes: 2 additions & 5 deletions lib/format/css.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
'use strict';

module.exports = function (codes) {
return function customizedFormatHTML(req, res, body) {
if (typeof (body) === 'string')
return body;

return '';
return function customizedFormatCSS(req, res, body) {
return res.formatters['text/html'](req, res, body);
};
};
2 changes: 2 additions & 0 deletions lib/format/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ module.exports = function (codes) {
if(typeof body === 'object') {
return res.formatters['application/json'](req, res, body);
} else {
body = body.toString();
res.setHeader('Content-Length', Buffer.byteLength(body));
return body;
}
};
Expand Down
1 change: 0 additions & 1 deletion lib/format/json.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ module.exports = function (codes) {

var data = JSON.stringify(body);
res.setHeader('Content-Length', Buffer.byteLength(data));
res.setHeader('Content-Type', 'application/json');

return data;
};
Expand Down
6 changes: 5 additions & 1 deletion lib/format/png.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

module.exports = function (codes) {
return function customizedFormatPNG(req, res, body) {
return body;
if(typeof body === 'object') {
return res.formatters['application/json'](req, res, body);
} else {
return body;
}
};
};

0 comments on commit 7acb92c

Please sign in to comment.