'use strict'; const { fail } = require('../core/ledger'); const send = (res, status, data, contentType = 'application/json; charset=utf-8') => { if (contentType.startsWith('text/html') && res.remainingBusinessTime) { const remaining = Math.max(0, res.remainingBusinessTime()); data = data .toString() .replace('', ``); } res.writeHead(status, { 'Content-Type': contentType }); res.end(contentType.startsWith('application/json') ? JSON.stringify(data) : data); }; const notFound = () => fail('地址不存在', 404); const HTML = 'text/html; charset=utf-8'; module.exports = { send, notFound, HTML };